@@ -23,7 +23,6 @@ |
||
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Set secret API Key. |
26 | - * @param string $key |
|
27 | 26 | */ |
28 | 27 | public static function set_secret_key( $secret_key ) { |
29 | 28 | self::$secret_key = $secret_key; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * Set secret API Key. |
27 | 27 | * @param string $key |
28 | 28 | */ |
29 | - public static function set_secret_key( $secret_key ) { |
|
29 | + public static function set_secret_key($secret_key) { |
|
30 | 30 | self::$secret_key = $secret_key; |
31 | 31 | } |
32 | 32 | |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | * @return string |
36 | 36 | */ |
37 | 37 | public static function get_secret_key() { |
38 | - if ( ! self::$secret_key ) { |
|
39 | - $options = get_option( 'woocommerce_stripe_settings' ); |
|
38 | + if ( ! self::$secret_key) { |
|
39 | + $options = get_option('woocommerce_stripe_settings'); |
|
40 | 40 | |
41 | - if ( isset( $options['testmode'], $options['secret_key'], $options['test_secret_key'] ) ) { |
|
42 | - self::set_secret_key( 'yes' === $options['testmode'] ? $options['test_secret_key'] : $options['secret_key'] ); |
|
41 | + if (isset($options['testmode'], $options['secret_key'], $options['test_secret_key'])) { |
|
42 | + self::set_secret_key('yes' === $options['testmode'] ? $options['test_secret_key'] : $options['secret_key']); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | return self::$secret_key; |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $user_agent = self::get_user_agent(); |
79 | 79 | $app_info = $user_agent['application']; |
80 | 80 | |
81 | - return apply_filters( 'woocommerce_stripe_request_headers', array( |
|
82 | - 'Authorization' => 'Basic ' . base64_encode( self::get_secret_key() . ':' ), |
|
81 | + return apply_filters('woocommerce_stripe_request_headers', array( |
|
82 | + 'Authorization' => 'Basic ' . base64_encode(self::get_secret_key() . ':'), |
|
83 | 83 | 'Stripe-Version' => self::STRIPE_API_VERSION, |
84 | 84 | 'User-Agent' => $app_info['name'] . '/' . $app_info['version'] . ' (' . $app_info['url'] . ')', |
85 | - 'X-Stripe-Client-User-Agent' => json_encode( $user_agent ), |
|
86 | - ) ); |
|
85 | + 'X-Stripe-Client-User-Agent' => json_encode($user_agent), |
|
86 | + )); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * @param bool $with_headers To get the response with headers. |
97 | 97 | * @return array|WP_Error |
98 | 98 | */ |
99 | - public static function request( $request, $api = 'charges', $method = 'POST', $with_headers = false ) { |
|
100 | - WC_Stripe_Logger::log( "{$api} request: " . print_r( $request, true ) ); |
|
99 | + public static function request($request, $api = 'charges', $method = 'POST', $with_headers = false) { |
|
100 | + WC_Stripe_Logger::log("{$api} request: " . print_r($request, true)); |
|
101 | 101 | |
102 | 102 | $headers = self::get_headers(); |
103 | 103 | |
104 | - if ( 'charges' === $api && 'POST' === $method ) { |
|
105 | - $customer = ! empty( $request['customer'] ) ? $request['customer'] : ''; |
|
106 | - $source = ! empty( $request['source'] ) ? $request['source'] : $customer; |
|
104 | + if ('charges' === $api && 'POST' === $method) { |
|
105 | + $customer = ! empty($request['customer']) ? $request['customer'] : ''; |
|
106 | + $source = ! empty($request['source']) ? $request['source'] : $customer; |
|
107 | 107 | |
108 | - $headers['Idempotency-Key'] = apply_filters( 'wc_stripe_idempotency_key', $request['metadata']['order_id'] . '-' . $source, $request ); |
|
108 | + $headers['Idempotency-Key'] = apply_filters('wc_stripe_idempotency_key', $request['metadata']['order_id'] . '-' . $source, $request); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | $response = wp_safe_remote_post( |
@@ -113,21 +113,21 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'method' => $method, |
115 | 115 | 'headers' => $headers, |
116 | - 'body' => apply_filters( 'woocommerce_stripe_request_body', $request, $api ), |
|
116 | + 'body' => apply_filters('woocommerce_stripe_request_body', $request, $api), |
|
117 | 117 | 'timeout' => 70, |
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | |
121 | - if ( is_wp_error( $response ) || empty( $response['body'] ) ) { |
|
122 | - WC_Stripe_Logger::log( 'Error Response: ' . print_r( $response, true ) ); |
|
123 | - throw new WC_Stripe_Exception( print_r( $response, true ), __( 'There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe' ) ); |
|
121 | + if (is_wp_error($response) || empty($response['body'])) { |
|
122 | + WC_Stripe_Logger::log('Error Response: ' . print_r($response, true)); |
|
123 | + throw new WC_Stripe_Exception(print_r($response, true), __('There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe')); |
|
124 | 124 | } |
125 | 125 | |
126 | - if ( $with_headers ) { |
|
127 | - return array( 'headers' => wp_remote_retrieve_headers( $response ), 'body' => json_decode( $response['body'] ) ); |
|
126 | + if ($with_headers) { |
|
127 | + return array('headers' => wp_remote_retrieve_headers($response), 'body' => json_decode($response['body'])); |
|
128 | 128 | } |
129 | 129 | |
130 | - return json_decode( $response['body'] ); |
|
130 | + return json_decode($response['body']); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | * @version 4.0.0 |
138 | 138 | * @param string $api |
139 | 139 | */ |
140 | - public static function retrieve( $api ) { |
|
141 | - WC_Stripe_Logger::log( "{$api}" ); |
|
140 | + public static function retrieve($api) { |
|
141 | + WC_Stripe_Logger::log("{$api}"); |
|
142 | 142 | |
143 | 143 | $response = wp_safe_remote_get( |
144 | 144 | self::ENDPOINT . $api, |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | |
152 | - if ( is_wp_error( $response ) || empty( $response['body'] ) ) { |
|
153 | - WC_Stripe_Logger::log( 'Error Response: ' . print_r( $response, true ) ); |
|
154 | - return new WP_Error( 'stripe_error', __( 'There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe' ) ); |
|
152 | + if (is_wp_error($response) || empty($response['body'])) { |
|
153 | + WC_Stripe_Logger::log('Error Response: ' . print_r($response, true)); |
|
154 | + return new WP_Error('stripe_error', __('There was a problem connecting to the Stripe API endpoint.', 'woocommerce-gateway-stripe')); |
|
155 | 155 | } |
156 | 156 | |
157 | - return json_decode( $response['body'] ); |
|
157 | + return json_decode($response['body']); |
|
158 | 158 | } |
159 | 159 | } |
@@ -289,7 +289,7 @@ |
||
289 | 289 | * |
290 | 290 | * @param int $order_id Reference. |
291 | 291 | * @param bool $retry Should we retry on fail. |
292 | - * @param bool $force_save_source Force payment source to be saved. |
|
292 | + * @param bool $force_save_save Force payment source to be saved. |
|
293 | 293 | * |
294 | 294 | * @throws Exception If payment will not be accepted. |
295 | 295 | * |
@@ -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_alipay'; |
60 | - $this->method_title = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
60 | + $this->method_title = __('Stripe Alipay', '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,25 +71,25 @@ 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( 'admin_notices', array( $this, 'check_environment' ) ); |
|
91 | - add_action( 'admin_head', array( $this, 'remove_admin_notice' ) ); |
|
92 | - 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('admin_notices', array($this, 'check_environment')); |
|
91 | + add_action('admin_head', array($this, 'remove_admin_notice')); |
|
92 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | * @version 4.0.0 |
100 | 100 | */ |
101 | 101 | public function check_environment() { |
102 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
102 | + if ( ! current_user_can('manage_woocommerce')) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $environment_warning = $this->get_environment_warning(); |
107 | 107 | |
108 | - if ( $environment_warning ) { |
|
109 | - $this->add_admin_notice( 'bad_environment', 'error', $environment_warning ); |
|
108 | + if ($environment_warning) { |
|
109 | + $this->add_admin_notice('bad_environment', 'error', $environment_warning); |
|
110 | 110 | } |
111 | 111 | |
112 | - foreach ( (array) $this->notices as $notice_key => $notice ) { |
|
113 | - echo "<div class='" . esc_attr( $notice['class'] ) . "'><p>"; |
|
114 | - echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); |
|
112 | + foreach ((array) $this->notices as $notice_key => $notice) { |
|
113 | + echo "<div class='" . esc_attr($notice['class']) . "'><p>"; |
|
114 | + echo wp_kses($notice['message'], array('a' => array('href' => array()))); |
|
115 | 115 | echo '</p></div>'; |
116 | 116 | } |
117 | 117 | } |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function get_environment_warning() { |
127 | 127 | if ( |
128 | - 'yes' === $this->enabled && ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) |
|
128 | + 'yes' === $this->enabled && ! in_array(get_woocommerce_currency(), $this->get_supported_currency()) |
|
129 | 129 | ) { |
130 | 130 | /* translators: supported currency list */ |
131 | - $message = sprintf( __( 'Alipay is enabled - it requires store currency to be set to %s', 'woocommerce-gateway-stripe' ), implode( ', ', $this->get_supported_currency() ) ); |
|
131 | + $message = sprintf(__('Alipay is enabled - it requires store currency to be set to %s', 'woocommerce-gateway-stripe'), implode(', ', $this->get_supported_currency())); |
|
132 | 132 | |
133 | 133 | return $message; |
134 | 134 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return array |
145 | 145 | */ |
146 | 146 | public function get_supported_currency() { |
147 | - return apply_filters( 'wc_stripe_alipay_supported_currencies', array( |
|
147 | + return apply_filters('wc_stripe_alipay_supported_currencies', array( |
|
148 | 148 | 'EUR', |
149 | 149 | 'AUD', |
150 | 150 | 'CAD', |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | 'NZD', |
155 | 155 | 'SGD', |
156 | 156 | 'USD', |
157 | - ) ); |
|
157 | + )); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @return bool |
166 | 166 | */ |
167 | 167 | public function is_available() { |
168 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
168 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | $icons_str .= $icons['alipay']; |
188 | 188 | |
189 | - return apply_filters( 'woocommerce_gateway_icon', $icons_str, $this->id ); |
|
189 | + return apply_filters('woocommerce_gateway_icon', $icons_str, $this->id); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,19 +196,19 @@ discard block |
||
196 | 196 | * @version 4.0.0 |
197 | 197 | */ |
198 | 198 | public function payment_scripts() { |
199 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
199 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | 202 | |
203 | - wp_enqueue_style( 'stripe_paymentfonts' ); |
|
204 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
203 | + wp_enqueue_style('stripe_paymentfonts'); |
|
204 | + wp_enqueue_script('woocommerce_stripe'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Initialize Gateway Settings Form Fields. |
209 | 209 | */ |
210 | 210 | public function init_form_fields() { |
211 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-alipay-settings.php' ); |
|
211 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-alipay-settings.php'); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -219,25 +219,25 @@ discard block |
||
219 | 219 | $total = WC()->cart->total; |
220 | 220 | |
221 | 221 | // If paying from order, we need to get total from order not cart. |
222 | - if ( isset( $_GET['pay_for_order'] ) && ! empty( $_GET['key'] ) ) { |
|
223 | - $order = wc_get_order( wc_get_order_id_by_order_key( wc_clean( $_GET['key'] ) ) ); |
|
222 | + if (isset($_GET['pay_for_order']) && ! empty($_GET['key'])) { |
|
223 | + $order = wc_get_order(wc_get_order_id_by_order_key(wc_clean($_GET['key']))); |
|
224 | 224 | $total = $order->get_total(); |
225 | 225 | } |
226 | 226 | |
227 | - if ( is_add_payment_method_page() ) { |
|
228 | - $pay_button_text = __( 'Add Payment', 'woocommerce-gateway-stripe' ); |
|
229 | - $total = ''; |
|
227 | + if (is_add_payment_method_page()) { |
|
228 | + $pay_button_text = __('Add Payment', 'woocommerce-gateway-stripe'); |
|
229 | + $total = ''; |
|
230 | 230 | } else { |
231 | 231 | $pay_button_text = ''; |
232 | 232 | } |
233 | 233 | |
234 | 234 | echo '<div |
235 | 235 | id="stripe-alipay-payment-data" |
236 | - data-amount="' . esc_attr( WC_Stripe_Helper::get_stripe_amount( $total ) ) . '" |
|
237 | - data-currency="' . esc_attr( strtolower( get_woocommerce_currency() ) ) . '">'; |
|
236 | + data-amount="' . esc_attr(WC_Stripe_Helper::get_stripe_amount($total)) . '" |
|
237 | + data-currency="' . esc_attr(strtolower(get_woocommerce_currency())) . '">'; |
|
238 | 238 | |
239 | - if ( $this->description ) { |
|
240 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $this->description ) ) ); |
|
239 | + if ($this->description) { |
|
240 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($this->description))); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | echo '</div>'; |
@@ -251,24 +251,24 @@ discard block |
||
251 | 251 | * @param object $order |
252 | 252 | * @return mixed |
253 | 253 | */ |
254 | - public function create_source( $order ) { |
|
254 | + public function create_source($order) { |
|
255 | 255 | $currency = WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency(); |
256 | 256 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
257 | - $return_url = $this->get_stripe_return_url( $order ); |
|
257 | + $return_url = $this->get_stripe_return_url($order); |
|
258 | 258 | $post_data = array(); |
259 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $currency ); |
|
260 | - $post_data['currency'] = strtolower( $currency ); |
|
259 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $currency); |
|
260 | + $post_data['currency'] = strtolower($currency); |
|
261 | 261 | $post_data['type'] = 'alipay'; |
262 | - $post_data['owner'] = $this->get_owner_details( $order ); |
|
263 | - $post_data['redirect'] = array( 'return_url' => $return_url ); |
|
262 | + $post_data['owner'] = $this->get_owner_details($order); |
|
263 | + $post_data['redirect'] = array('return_url' => $return_url); |
|
264 | 264 | |
265 | - if ( ! empty( $this->statement_descriptor ) ) { |
|
266 | - $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $this->statement_descriptor ); |
|
265 | + if ( ! empty($this->statement_descriptor)) { |
|
266 | + $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($this->statement_descriptor); |
|
267 | 267 | } |
268 | 268 | |
269 | - WC_Stripe_Logger::log( 'Info: Begin creating Alipay source' ); |
|
269 | + WC_Stripe_Logger::log('Info: Begin creating Alipay source'); |
|
270 | 270 | |
271 | - return WC_Stripe_API::request( apply_filters( 'wc_stripe_alipay_source', $post_data, $order ), 'sources' ); |
|
271 | + return WC_Stripe_API::request(apply_filters('wc_stripe_alipay_source', $post_data, $order), 'sources'); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -282,53 +282,53 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return array|void |
284 | 284 | */ |
285 | - public function process_payment( $order_id, $retry = true, $force_save_save = false ) { |
|
285 | + public function process_payment($order_id, $retry = true, $force_save_save = false) { |
|
286 | 286 | try { |
287 | - $order = wc_get_order( $order_id ); |
|
287 | + $order = wc_get_order($order_id); |
|
288 | 288 | |
289 | 289 | // This will throw exception if not valid. |
290 | - $this->validate_minimum_order_amount( $order ); |
|
290 | + $this->validate_minimum_order_amount($order); |
|
291 | 291 | |
292 | 292 | // This comes from the create account checkbox in the checkout page. |
293 | - $create_account = ! empty( $_POST['createaccount'] ) ? true : false; |
|
293 | + $create_account = ! empty($_POST['createaccount']) ? true : false; |
|
294 | 294 | |
295 | - if ( $create_account ) { |
|
295 | + if ($create_account) { |
|
296 | 296 | $new_customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); |
297 | - $new_stripe_customer = new WC_Stripe_Customer( $new_customer_id ); |
|
297 | + $new_stripe_customer = new WC_Stripe_Customer($new_customer_id); |
|
298 | 298 | $new_stripe_customer->create_customer(); |
299 | 299 | } |
300 | 300 | |
301 | - $response = $this->create_source( $order ); |
|
301 | + $response = $this->create_source($order); |
|
302 | 302 | |
303 | - if ( ! empty( $response->error ) ) { |
|
304 | - $order->add_order_note( $response->error->message ); |
|
303 | + if ( ! empty($response->error)) { |
|
304 | + $order->add_order_note($response->error->message); |
|
305 | 305 | |
306 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
306 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
307 | 307 | } |
308 | 308 | |
309 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
310 | - update_post_meta( $order_id, '_stripe_source_id', $response->id ); |
|
309 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
310 | + update_post_meta($order_id, '_stripe_source_id', $response->id); |
|
311 | 311 | } else { |
312 | - $order->update_meta_data( '_stripe_source_id', $response->id ); |
|
312 | + $order->update_meta_data('_stripe_source_id', $response->id); |
|
313 | 313 | $order->save(); |
314 | 314 | } |
315 | 315 | |
316 | - WC_Stripe_Logger::log( 'Info: Redirecting to Alipay...' ); |
|
316 | + WC_Stripe_Logger::log('Info: Redirecting to Alipay...'); |
|
317 | 317 | |
318 | 318 | return array( |
319 | 319 | 'result' => 'success', |
320 | - 'redirect' => esc_url_raw( $response->redirect->url ), |
|
320 | + 'redirect' => esc_url_raw($response->redirect->url), |
|
321 | 321 | ); |
322 | - } catch ( WC_Stripe_Exception $e ) { |
|
323 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
324 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
322 | + } catch (WC_Stripe_Exception $e) { |
|
323 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
324 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
325 | 325 | |
326 | - do_action( 'wc_gateway_stripe_process_payment_error', $e, $order ); |
|
326 | + do_action('wc_gateway_stripe_process_payment_error', $e, $order); |
|
327 | 327 | |
328 | - $statuses = array( 'pending', 'failed' ); |
|
328 | + $statuses = array('pending', 'failed'); |
|
329 | 329 | |
330 | - if ( $order->has_status( $statuses ) ) { |
|
331 | - $this->send_failed_order_email( $order_id ); |
|
330 | + if ($order->has_status($statuses)) { |
|
331 | + $this->send_failed_order_email($order_id); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | return array( |
@@ -162,6 +162,8 @@ |
||
162 | 162 | * |
163 | 163 | * @since 1.0.0 |
164 | 164 | * @version 4.0.0 |
165 | + * @param string $slug |
|
166 | + * @param string $class |
|
165 | 167 | */ |
166 | 168 | public function add_admin_notice( $slug, $class, $message, $dismissible = false ) { |
167 | 169 | $this->notices[ $slug ] = array( |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * |
16 | 16 | */ |
17 | 17 | |
18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
18 | +if ( ! defined('ABSPATH')) { |
|
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | |
22 | -if ( ! class_exists( 'WC_Stripe' ) ) : |
|
22 | +if ( ! class_exists('WC_Stripe')) : |
|
23 | 23 | /** |
24 | 24 | * Required minimums and constants |
25 | 25 | */ |
26 | - define( 'WC_STRIPE_VERSION', '4.0.5' ); |
|
27 | - define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' ); |
|
28 | - define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' ); |
|
29 | - define( 'WC_STRIPE_MAIN_FILE', __FILE__ ); |
|
30 | - define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
|
31 | - define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
26 | + define('WC_STRIPE_VERSION', '4.0.5'); |
|
27 | + define('WC_STRIPE_MIN_PHP_VER', '5.6.0'); |
|
28 | + define('WC_STRIPE_MIN_WC_VER', '2.6.0'); |
|
29 | + define('WC_STRIPE_MAIN_FILE', __FILE__); |
|
30 | + define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
|
31 | + define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
32 | 32 | |
33 | 33 | class WC_Stripe { |
34 | 34 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return Singleton The *Singleton* instance. |
49 | 49 | */ |
50 | 50 | public static function get_instance() { |
51 | - if ( null === self::$instance ) { |
|
51 | + if (null === self::$instance) { |
|
52 | 52 | self::$instance = new self(); |
53 | 53 | } |
54 | 54 | return self::$instance; |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * *Singleton* via the `new` operator from outside of this class. |
82 | 82 | */ |
83 | 83 | private function __construct() { |
84 | - add_action( 'admin_init', array( $this, 'check_environment' ) ); |
|
85 | - add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 ); |
|
86 | - add_action( 'plugins_loaded', array( $this, 'init' ) ); |
|
87 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
84 | + add_action('admin_init', array($this, 'check_environment')); |
|
85 | + add_action('admin_notices', array($this, 'admin_notices'), 15); |
|
86 | + add_action('plugins_loaded', array($this, 'init')); |
|
87 | + add_action('wp_loaded', array($this, 'hide_notices')); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,44 +94,44 @@ discard block |
||
94 | 94 | * @version 4.0.0 |
95 | 95 | */ |
96 | 96 | public function init() { |
97 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php' ); |
|
98 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php' ); |
|
99 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php' ); |
|
100 | - include_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php' ); |
|
97 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-exception.php'); |
|
98 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'); |
|
99 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'); |
|
100 | + include_once(dirname(__FILE__) . '/includes/class-wc-stripe-api.php'); |
|
101 | 101 | |
102 | 102 | // Don't hook anything else in the plugin if we're in an incompatible environment. |
103 | - if ( self::get_environment_warning() ) { |
|
103 | + if (self::get_environment_warning()) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
107 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
108 | - |
|
109 | - require_once( dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php' ); |
|
110 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php' ); |
|
111 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php' ); |
|
112 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php' ); |
|
113 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php' ); |
|
114 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php' ); |
|
115 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php' ); |
|
116 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php' ); |
|
117 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php' ); |
|
118 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php' ); |
|
119 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php' ); |
|
120 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php' ); |
|
121 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bitcoin.php' ); |
|
122 | - require_once( dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php' ); |
|
123 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-compat.php' ); |
|
124 | - require_once( dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-compat.php' ); |
|
125 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php' ); |
|
126 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php' ); |
|
127 | - require_once( dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php' ); |
|
107 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
108 | + |
|
109 | + require_once(dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'); |
|
110 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'); |
|
111 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'); |
|
112 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php'); |
|
113 | + require_once(dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'); |
|
114 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'); |
|
115 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'); |
|
116 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'); |
|
117 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'); |
|
118 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'); |
|
119 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'); |
|
120 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'); |
|
121 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bitcoin.php'); |
|
122 | + require_once(dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'); |
|
123 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-compat.php'); |
|
124 | + require_once(dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-compat.php'); |
|
125 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'); |
|
126 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'); |
|
127 | + require_once(dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'); |
|
128 | 128 | |
129 | 129 | // REMOVE IN THE FUTURE. |
130 | - require_once( dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php' ); |
|
130 | + require_once(dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php'); |
|
131 | 131 | |
132 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
133 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
134 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
132 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
133 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
134 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -141,23 +141,23 @@ discard block |
||
141 | 141 | * @version 4.0.0 |
142 | 142 | */ |
143 | 143 | public function hide_notices() { |
144 | - if ( isset( $_GET['wc-stripe-hide-notice'] ) && isset( $_GET['_wc_stripe_notice_nonce'] ) ) { |
|
145 | - if ( ! wp_verify_nonce( $_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce' ) ) { |
|
146 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe' ) ); |
|
144 | + if (isset($_GET['wc-stripe-hide-notice']) && isset($_GET['_wc_stripe_notice_nonce'])) { |
|
145 | + if ( ! wp_verify_nonce($_GET['_wc_stripe_notice_nonce'], 'wc_stripe_hide_notices_nonce')) { |
|
146 | + wp_die(__('Action failed. Please refresh the page and retry.', 'woocommerce-gateway-stripe')); |
|
147 | 147 | } |
148 | 148 | |
149 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
150 | - wp_die( __( 'Cheatin’ huh?', 'woocommerce-gateway-stripe' ) ); |
|
149 | + if ( ! current_user_can('manage_woocommerce')) { |
|
150 | + wp_die(__('Cheatin’ huh?', 'woocommerce-gateway-stripe')); |
|
151 | 151 | } |
152 | 152 | |
153 | - $notice = wc_clean( $_GET['wc-stripe-hide-notice'] ); |
|
153 | + $notice = wc_clean($_GET['wc-stripe-hide-notice']); |
|
154 | 154 | |
155 | - switch ( $notice ) { |
|
155 | + switch ($notice) { |
|
156 | 156 | case 'ssl': |
157 | - update_option( 'wc_stripe_show_ssl_notice', 'no' ); |
|
157 | + update_option('wc_stripe_show_ssl_notice', 'no'); |
|
158 | 158 | break; |
159 | 159 | case 'keys': |
160 | - update_option( 'wc_stripe_show_keys_notice', 'no' ); |
|
160 | + update_option('wc_stripe_show_keys_notice', 'no'); |
|
161 | 161 | break; |
162 | 162 | } |
163 | 163 | } |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * @since 1.0.0 |
170 | 170 | * @version 4.0.0 |
171 | 171 | */ |
172 | - public function add_admin_notice( $slug, $class, $message, $dismissible = false ) { |
|
173 | - $this->notices[ $slug ] = array( |
|
172 | + public function add_admin_notice($slug, $class, $message, $dismissible = false) { |
|
173 | + $this->notices[$slug] = array( |
|
174 | 174 | 'class' => $class, |
175 | 175 | 'message' => $message, |
176 | 176 | 'dismissible' => $dismissible, |
@@ -184,21 +184,21 @@ discard block |
||
184 | 184 | * @version 4.0.0 |
185 | 185 | */ |
186 | 186 | public function admin_notices() { |
187 | - if ( ! current_user_can( 'manage_woocommerce' ) ) { |
|
187 | + if ( ! current_user_can('manage_woocommerce')) { |
|
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | - foreach ( (array) $this->notices as $notice_key => $notice ) { |
|
192 | - echo '<div class="' . esc_attr( $notice['class'] ) . '" style="position:relative;">'; |
|
191 | + foreach ((array) $this->notices as $notice_key => $notice) { |
|
192 | + echo '<div class="' . esc_attr($notice['class']) . '" style="position:relative;">'; |
|
193 | 193 | |
194 | - if ( $notice['dismissible'] ) { |
|
194 | + if ($notice['dismissible']) { |
|
195 | 195 | ?> |
196 | - <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:absolute;right:1px;padding:9px;text-decoration:none;"></a> |
|
196 | + <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:absolute;right:1px;padding:9px;text-decoration:none;"></a> |
|
197 | 197 | <?php |
198 | 198 | } |
199 | 199 | |
200 | 200 | echo '<p>'; |
201 | - echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); |
|
201 | + echo wp_kses($notice['message'], array('a' => array('href' => array()))); |
|
202 | 202 | echo '</p></div>'; |
203 | 203 | } |
204 | 204 | } |
@@ -211,26 +211,26 @@ discard block |
||
211 | 211 | * @version 4.0.0 |
212 | 212 | */ |
213 | 213 | public function get_environment_warning() { |
214 | - if ( version_compare( phpversion(), WC_STRIPE_MIN_PHP_VER, '<' ) ) { |
|
214 | + if (version_compare(phpversion(), WC_STRIPE_MIN_PHP_VER, '<')) { |
|
215 | 215 | /* translators: 1) int version 2) int version */ |
216 | - $message = __( 'WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
216 | + $message = __('WooCommerce Stripe - The minimum PHP version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
217 | 217 | |
218 | - return sprintf( $message, WC_STRIPE_MIN_PHP_VER, phpversion() ); |
|
218 | + return sprintf($message, WC_STRIPE_MIN_PHP_VER, phpversion()); |
|
219 | 219 | } |
220 | 220 | |
221 | - if ( ! defined( 'WC_VERSION' ) ) { |
|
222 | - return __( 'WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe' ); |
|
221 | + if ( ! defined('WC_VERSION')) { |
|
222 | + return __('WooCommerce Stripe requires WooCommerce to be activated to work.', 'woocommerce-gateway-stripe'); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
225 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
226 | 226 | /* translators: 1) int version 2) int version */ |
227 | - $message = __( 'WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe' ); |
|
227 | + $message = __('WooCommerce Stripe - The minimum WooCommerce version required for this plugin is %1$s. You are running %2$s.', 'woocommerce-gateway-stripe'); |
|
228 | 228 | |
229 | - return sprintf( $message, WC_STRIPE_MIN_WC_VER, WC_VERSION ); |
|
229 | + return sprintf($message, WC_STRIPE_MIN_WC_VER, WC_VERSION); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( ! function_exists( 'curl_init' ) ) { |
|
233 | - return __( 'WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe' ); |
|
232 | + if ( ! function_exists('curl_init')) { |
|
233 | + return __('WooCommerce Stripe - cURL is not installed.', 'woocommerce-gateway-stripe'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | return false; |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @return string Setting link |
245 | 245 | */ |
246 | 246 | public function get_setting_link() { |
247 | - $use_id_as_section = function_exists( 'WC' ) ? version_compare( WC()->version, '2.6', '>=' ) : false; |
|
247 | + $use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false; |
|
248 | 248 | |
249 | - $section_slug = $use_id_as_section ? 'stripe' : strtolower( 'WC_Gateway_Stripe' ); |
|
249 | + $section_slug = $use_id_as_section ? 'stripe' : strtolower('WC_Gateway_Stripe'); |
|
250 | 250 | |
251 | - return admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug ); |
|
251 | + return admin_url('admin.php?page=wc-settings&tab=checkout§ion=' . $section_slug); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -259,65 +259,65 @@ discard block |
||
259 | 259 | * @version 4.0.0 |
260 | 260 | */ |
261 | 261 | public function check_environment() { |
262 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
262 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
263 | 263 | $this->install(); |
264 | 264 | |
265 | - do_action( 'woocommerce_stripe_updated' ); |
|
265 | + do_action('woocommerce_stripe_updated'); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | $environment_warning = $this->get_environment_warning(); |
269 | 269 | |
270 | - if ( $environment_warning && is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
271 | - $this->add_admin_notice( 'bad_environment', 'error', $environment_warning ); |
|
270 | + if ($environment_warning && is_plugin_active(plugin_basename(__FILE__))) { |
|
271 | + $this->add_admin_notice('bad_environment', 'error', $environment_warning); |
|
272 | 272 | } |
273 | 273 | |
274 | - $show_ssl_notice = get_option( 'wc_stripe_show_ssl_notice' ); |
|
275 | - $show_keys_notice = get_option( 'wc_stripe_show_keys_notice' ); |
|
276 | - $options = get_option( 'woocommerce_stripe_settings' ); |
|
277 | - $testmode = ( isset( $options['testmode'] ) && 'yes' === $options['testmode'] ) ? true : false; |
|
278 | - $test_pub_key = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : ''; |
|
279 | - $test_secret_key = isset( $options['test_secret_key'] ) ? $options['test_secret_key'] : ''; |
|
280 | - $live_pub_key = isset( $options['publishable_key'] ) ? $options['publishable_key'] : ''; |
|
281 | - $live_secret_key = isset( $options['secret_key'] ) ? $options['secret_key'] : ''; |
|
274 | + $show_ssl_notice = get_option('wc_stripe_show_ssl_notice'); |
|
275 | + $show_keys_notice = get_option('wc_stripe_show_keys_notice'); |
|
276 | + $options = get_option('woocommerce_stripe_settings'); |
|
277 | + $testmode = (isset($options['testmode']) && 'yes' === $options['testmode']) ? true : false; |
|
278 | + $test_pub_key = isset($options['test_publishable_key']) ? $options['test_publishable_key'] : ''; |
|
279 | + $test_secret_key = isset($options['test_secret_key']) ? $options['test_secret_key'] : ''; |
|
280 | + $live_pub_key = isset($options['publishable_key']) ? $options['publishable_key'] : ''; |
|
281 | + $live_secret_key = isset($options['secret_key']) ? $options['secret_key'] : ''; |
|
282 | 282 | |
283 | - if ( isset( $options['enabled'] ) && 'yes' === $options['enabled'] && empty( $show_keys_notice ) ) { |
|
284 | - $secret = WC_Stripe_API::get_secret_key(); |
|
283 | + if (isset($options['enabled']) && 'yes' === $options['enabled'] && empty($show_keys_notice)) { |
|
284 | + $secret = WC_Stripe_API::get_secret_key(); |
|
285 | 285 | |
286 | - if ( empty( $secret ) && ! ( isset( $_GET['page'], $_GET['section'] ) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'] ) ) { |
|
286 | + if (empty($secret) && ! (isset($_GET['page'], $_GET['section']) && 'wc-settings' === $_GET['page'] && 'stripe' === $_GET['section'])) { |
|
287 | 287 | $setting_link = $this->get_setting_link(); |
288 | 288 | /* translators: 1) link */ |
289 | - $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 ); |
|
289 | + $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); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | // Check if keys are entered properly per live/test mode. |
293 | - if ( $testmode ) { |
|
293 | + if ($testmode) { |
|
294 | 294 | if ( |
295 | - ! empty( $test_pub_key ) && ! preg_match( '/^pk_test_/', $test_pub_key ) |
|
296 | - || ( ! empty( $test_secret_key ) && ! preg_match( '/^sk_test_/', $test_secret_key ) |
|
297 | - && ! empty( $test_secret_key ) && ! preg_match( '/^rk_test_/', $test_secret_key ) ) ) |
|
295 | + ! empty($test_pub_key) && ! preg_match('/^pk_test_/', $test_pub_key) |
|
296 | + || ( ! empty($test_secret_key) && ! preg_match('/^sk_test_/', $test_secret_key) |
|
297 | + && ! empty($test_secret_key) && ! preg_match('/^rk_test_/', $test_secret_key)) ) |
|
298 | 298 | { |
299 | 299 | $setting_link = $this->get_setting_link(); |
300 | 300 | /* translators: 1) link */ |
301 | - $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 ); |
|
301 | + $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); |
|
302 | 302 | } |
303 | 303 | } else { |
304 | 304 | if ( |
305 | - ! empty( $live_pub_key ) && ! preg_match( '/^pk_live_/', $live_pub_key ) |
|
306 | - || ( ! empty( $live_secret_key ) && ! preg_match( '/^sk_live_/', $live_secret_key ) |
|
307 | - && ! empty( $live_secret_key ) && ! preg_match( '/^rk_live_/', $live_secret_key ) ) ) |
|
305 | + ! empty($live_pub_key) && ! preg_match('/^pk_live_/', $live_pub_key) |
|
306 | + || ( ! empty($live_secret_key) && ! preg_match('/^sk_live_/', $live_secret_key) |
|
307 | + && ! empty($live_secret_key) && ! preg_match('/^rk_live_/', $live_secret_key)) ) |
|
308 | 308 | { |
309 | 309 | $setting_link = $this->get_setting_link(); |
310 | 310 | /* translators: 1) link */ |
311 | - $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 ); |
|
311 | + $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); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | - if ( empty( $show_ssl_notice ) && isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) { |
|
316 | + if (empty($show_ssl_notice) && isset($options['enabled']) && 'yes' === $options['enabled']) { |
|
317 | 317 | // Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected. |
318 | - if ( ( function_exists( 'wc_site_is_https' ) && ! wc_site_is_https() ) && ( 'no' === get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) ) { |
|
318 | + if ((function_exists('wc_site_is_https') && ! wc_site_is_https()) && ('no' === get_option('woocommerce_force_ssl_checkout') && ! class_exists('WordPressHTTPS'))) { |
|
319 | 319 | /* translators: 1) link 2) link */ |
320 | - $this->add_admin_notice( 'ssl', 'notice notice-warning', sprintf( __( 'Stripe is enabled, but the <a href="%1$s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid <a href="%2$s" target="_blank">SSL certificate</a> - Stripe will only work in test mode.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ), 'https://en.wikipedia.org/wiki/Transport_Layer_Security' ), true ); |
|
320 | + $this->add_admin_notice('ssl', 'notice notice-warning', sprintf(__('Stripe is enabled, but the <a href="%1$s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid <a href="%2$s" target="_blank">SSL certificate</a> - Stripe will only work in test mode.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout'), 'https://en.wikipedia.org/wiki/Transport_Layer_Security'), true); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | * @version 4.0.0 |
330 | 330 | */ |
331 | 331 | public function update_plugin_version() { |
332 | - delete_option( 'wc_stripe_version' ); |
|
333 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
332 | + delete_option('wc_stripe_version'); |
|
333 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @version 3.1.0 |
341 | 341 | */ |
342 | 342 | public function install() { |
343 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
344 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
343 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
344 | + define('WC_STRIPE_INSTALLING', true); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $this->update_plugin_version(); |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | * @since 1.0.0 |
354 | 354 | * @version 4.0.0 |
355 | 355 | */ |
356 | - public function plugin_action_links( $links ) { |
|
356 | + public function plugin_action_links($links) { |
|
357 | 357 | $plugin_links = array( |
358 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
359 | - '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>', |
|
360 | - '<a href="https://woocommerce.com/contact-us/">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>', |
|
358 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
359 | + '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>', |
|
360 | + '<a href="https://woocommerce.com/contact-us/">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>', |
|
361 | 361 | ); |
362 | - return array_merge( $plugin_links, $links ); |
|
362 | + return array_merge($plugin_links, $links); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * @since 1.0.0 |
369 | 369 | * @version 4.0.0 |
370 | 370 | */ |
371 | - public function add_gateways( $methods ) { |
|
372 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) || class_exists( 'WC_Pre_Orders_Order' ) ) { |
|
371 | + public function add_gateways($methods) { |
|
372 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order') || class_exists('WC_Pre_Orders_Order')) { |
|
373 | 373 | $methods[] = 'WC_Stripe_Compat'; |
374 | 374 | $methods[] = 'WC_Stripe_Sepa_Compat'; |
375 | 375 | } else { |
@@ -394,26 +394,26 @@ discard block |
||
394 | 394 | * @since 4.0.0 |
395 | 395 | * @version 4.0.0 |
396 | 396 | */ |
397 | - public function filter_gateway_order_admin( $sections ) { |
|
398 | - unset( $sections['stripe'] ); |
|
399 | - unset( $sections['stripe_bancontact'] ); |
|
400 | - unset( $sections['stripe_sofort'] ); |
|
401 | - unset( $sections['stripe_giropay'] ); |
|
402 | - unset( $sections['stripe_ideal'] ); |
|
403 | - unset( $sections['stripe_p24'] ); |
|
404 | - unset( $sections['stripe_alipay'] ); |
|
405 | - unset( $sections['stripe_sepa'] ); |
|
406 | - unset( $sections['stripe_bitcoin'] ); |
|
397 | + public function filter_gateway_order_admin($sections) { |
|
398 | + unset($sections['stripe']); |
|
399 | + unset($sections['stripe_bancontact']); |
|
400 | + unset($sections['stripe_sofort']); |
|
401 | + unset($sections['stripe_giropay']); |
|
402 | + unset($sections['stripe_ideal']); |
|
403 | + unset($sections['stripe_p24']); |
|
404 | + unset($sections['stripe_alipay']); |
|
405 | + unset($sections['stripe_sepa']); |
|
406 | + unset($sections['stripe_bitcoin']); |
|
407 | 407 | |
408 | 408 | $sections['stripe'] = 'Stripe'; |
409 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
410 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
411 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
412 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
413 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
414 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
415 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
416 | - $sections['stripe_bitcoin'] = __( 'Stripe Bitcoin', 'woocommerce-gateway-stripe' ); |
|
409 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
410 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
411 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
412 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
413 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
414 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
415 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
416 | + $sections['stripe_bitcoin'] = __('Stripe Bitcoin', 'woocommerce-gateway-stripe'); |
|
417 | 417 | |
418 | 418 | return $sections; |
419 | 419 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if ( ! defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | * @param string $deprecated Deprecated since WooCommerce 3.0 |
36 | 36 | * @return string |
37 | 37 | */ |
38 | - public function get_display_name( $deprecated = '' ) { |
|
38 | + public function get_display_name($deprecated = '') { |
|
39 | 39 | $display = sprintf( |
40 | 40 | /* translators: last 4 digits of IBAN account */ |
41 | - __( 'SEPA IBAN ending in %s', 'woocommerce-gateway-stripe' ), |
|
41 | + __('SEPA IBAN ending in %s', 'woocommerce-gateway-stripe'), |
|
42 | 42 | $this->get_last4() |
43 | 43 | ); |
44 | 44 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | * @return boolean True if the passed data is valid |
67 | 67 | */ |
68 | 68 | public function validate() { |
69 | - if ( false === parent::validate() ) { |
|
69 | + if (false === parent::validate()) { |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | - if ( ! $this->get_last4( 'edit' ) ) { |
|
73 | + if ( ! $this->get_last4('edit')) { |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param string $context |
86 | 86 | * @return string Last 4 digits |
87 | 87 | */ |
88 | - public function get_last4( $context = 'view' ) { |
|
89 | - return $this->get_prop( 'last4', $context ); |
|
88 | + public function get_last4($context = 'view') { |
|
89 | + return $this->get_prop('last4', $context); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @version 4.0.0 |
96 | 96 | * @param string $last4 |
97 | 97 | */ |
98 | - public function set_last4( $last4 ) { |
|
99 | - $this->set_prop( 'last4', $last4 ); |
|
98 | + public function set_last4($last4) { |
|
99 | + $this->set_prop('last4', $last4); |
|
100 | 100 | } |
101 | 101 | } |
@@ -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,11 +21,11 @@ discard block |
||
21 | 21 | public function __construct() { |
22 | 22 | self::$_this = $this; |
23 | 23 | |
24 | - add_filter( 'woocommerce_get_customer_payment_tokens', array( $this, 'woocommerce_get_customer_payment_tokens' ), 10, 3 ); |
|
25 | - add_filter( 'woocommerce_payment_methods_list_item', array( $this, 'get_account_saved_payment_methods_list_item_sepa' ), 10, 2 ); |
|
26 | - add_filter( 'woocommerce_get_credit_card_type_label', array( $this, 'normalize_sepa_label' ) ); |
|
27 | - add_action( 'woocommerce_payment_token_deleted', array( $this, 'woocommerce_payment_token_deleted' ), 10, 2 ); |
|
28 | - add_action( 'woocommerce_payment_token_set_default', array( $this, 'woocommerce_payment_token_set_default' ) ); |
|
24 | + add_filter('woocommerce_get_customer_payment_tokens', array($this, 'woocommerce_get_customer_payment_tokens'), 10, 3); |
|
25 | + add_filter('woocommerce_payment_methods_list_item', array($this, 'get_account_saved_payment_methods_list_item_sepa'), 10, 2); |
|
26 | + add_filter('woocommerce_get_credit_card_type_label', array($this, 'normalize_sepa_label')); |
|
27 | + add_action('woocommerce_payment_token_deleted', array($this, 'woocommerce_payment_token_deleted'), 10, 2); |
|
28 | + add_action('woocommerce_payment_token_set_default', array($this, 'woocommerce_payment_token_set_default')); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param string $label |
47 | 47 | * @return string $label |
48 | 48 | */ |
49 | - public function normalize_sepa_label( $label ) { |
|
50 | - if ( 'sepa iban' === strtolower( $label ) ) { |
|
49 | + public function normalize_sepa_label($label) { |
|
50 | + if ('sepa iban' === strtolower($label)) { |
|
51 | 51 | return 'SEPA IBAN'; |
52 | 52 | } |
53 | 53 | |
@@ -62,67 +62,67 @@ discard block |
||
62 | 62 | * @param array $tokens |
63 | 63 | * @return array |
64 | 64 | */ |
65 | - public function woocommerce_get_customer_payment_tokens( $tokens = array(), $customer_id, $gateway_id ) { |
|
66 | - if ( is_user_logged_in() && class_exists( 'WC_Payment_Token_CC' ) ) { |
|
65 | + public function woocommerce_get_customer_payment_tokens($tokens = array(), $customer_id, $gateway_id) { |
|
66 | + if (is_user_logged_in() && class_exists('WC_Payment_Token_CC')) { |
|
67 | 67 | $stored_tokens = array(); |
68 | 68 | |
69 | - foreach ( $tokens as $token ) { |
|
69 | + foreach ($tokens as $token) { |
|
70 | 70 | $stored_tokens[] = $token->get_token(); |
71 | 71 | } |
72 | 72 | |
73 | - if ( 'stripe' === $gateway_id ) { |
|
74 | - $stripe_customer = new WC_Stripe_Customer( $customer_id ); |
|
73 | + if ('stripe' === $gateway_id) { |
|
74 | + $stripe_customer = new WC_Stripe_Customer($customer_id); |
|
75 | 75 | $stripe_sources = $stripe_customer->get_sources(); |
76 | 76 | |
77 | - foreach ( $stripe_sources as $source ) { |
|
78 | - if ( isset( $source->type ) && 'card' === $source->type ) { |
|
79 | - if ( ! in_array( $source->id, $stored_tokens ) ) { |
|
77 | + foreach ($stripe_sources as $source) { |
|
78 | + if (isset($source->type) && 'card' === $source->type) { |
|
79 | + if ( ! in_array($source->id, $stored_tokens)) { |
|
80 | 80 | $token = new WC_Payment_Token_CC(); |
81 | - $token->set_token( $source->id ); |
|
82 | - $token->set_gateway_id( 'stripe' ); |
|
83 | - |
|
84 | - if ( 'source' === $source->object && 'card' === $source->type ) { |
|
85 | - $token->set_card_type( strtolower( $source->card->brand ) ); |
|
86 | - $token->set_last4( $source->card->last4 ); |
|
87 | - $token->set_expiry_month( $source->card->exp_month ); |
|
88 | - $token->set_expiry_year( $source->card->exp_year ); |
|
81 | + $token->set_token($source->id); |
|
82 | + $token->set_gateway_id('stripe'); |
|
83 | + |
|
84 | + if ('source' === $source->object && 'card' === $source->type) { |
|
85 | + $token->set_card_type(strtolower($source->card->brand)); |
|
86 | + $token->set_last4($source->card->last4); |
|
87 | + $token->set_expiry_month($source->card->exp_month); |
|
88 | + $token->set_expiry_year($source->card->exp_year); |
|
89 | 89 | } |
90 | 90 | |
91 | - $token->set_user_id( $customer_id ); |
|
91 | + $token->set_user_id($customer_id); |
|
92 | 92 | $token->save(); |
93 | - $tokens[ $token->get_id() ] = $token; |
|
93 | + $tokens[$token->get_id()] = $token; |
|
94 | 94 | } |
95 | 95 | } else { |
96 | - if ( ! in_array( $source->id, $stored_tokens ) && 'card' === $source->object ) { |
|
96 | + if ( ! in_array($source->id, $stored_tokens) && 'card' === $source->object) { |
|
97 | 97 | $token = new WC_Payment_Token_CC(); |
98 | - $token->set_token( $source->id ); |
|
99 | - $token->set_gateway_id( 'stripe' ); |
|
100 | - $token->set_card_type( strtolower( $source->brand ) ); |
|
101 | - $token->set_last4( $source->last4 ); |
|
102 | - $token->set_expiry_month( $source->exp_month ); |
|
103 | - $token->set_expiry_year( $source->exp_year ); |
|
104 | - $token->set_user_id( $customer_id ); |
|
98 | + $token->set_token($source->id); |
|
99 | + $token->set_gateway_id('stripe'); |
|
100 | + $token->set_card_type(strtolower($source->brand)); |
|
101 | + $token->set_last4($source->last4); |
|
102 | + $token->set_expiry_month($source->exp_month); |
|
103 | + $token->set_expiry_year($source->exp_year); |
|
104 | + $token->set_user_id($customer_id); |
|
105 | 105 | $token->save(); |
106 | - $tokens[ $token->get_id() ] = $token; |
|
106 | + $tokens[$token->get_id()] = $token; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if ( 'stripe_sepa' === $gateway_id ) { |
|
113 | - $stripe_customer = new WC_Stripe_Customer( $customer_id ); |
|
112 | + if ('stripe_sepa' === $gateway_id) { |
|
113 | + $stripe_customer = new WC_Stripe_Customer($customer_id); |
|
114 | 114 | $stripe_sources = $stripe_customer->get_sources(); |
115 | 115 | |
116 | - foreach ( $stripe_sources as $source ) { |
|
117 | - if ( isset( $source->type ) && 'sepa_debit' === $source->type ) { |
|
118 | - if ( ! in_array( $source->id, $stored_tokens ) ) { |
|
116 | + foreach ($stripe_sources as $source) { |
|
117 | + if (isset($source->type) && 'sepa_debit' === $source->type) { |
|
118 | + if ( ! in_array($source->id, $stored_tokens)) { |
|
119 | 119 | $token = new WC_Payment_Token_SEPA(); |
120 | - $token->set_token( $source->id ); |
|
121 | - $token->set_gateway_id( 'stripe_sepa' ); |
|
122 | - $token->set_last4( $source->sepa_debit->last4 ); |
|
123 | - $token->set_user_id( $customer_id ); |
|
120 | + $token->set_token($source->id); |
|
121 | + $token->set_gateway_id('stripe_sepa'); |
|
122 | + $token->set_last4($source->sepa_debit->last4); |
|
123 | + $token->set_user_id($customer_id); |
|
124 | 124 | $token->save(); |
125 | - $tokens[ $token->get_id() ] = $token; |
|
125 | + $tokens[$token->get_id()] = $token; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * @param WC_Payment_Token $payment_token The payment token associated with this method entry |
142 | 142 | * @return array Filtered item |
143 | 143 | */ |
144 | - public function get_account_saved_payment_methods_list_item_sepa( $item, $payment_token ) { |
|
145 | - if ( 'sepa' !== strtolower( $payment_token->get_type() ) ) { |
|
144 | + public function get_account_saved_payment_methods_list_item_sepa($item, $payment_token) { |
|
145 | + if ('sepa' !== strtolower($payment_token->get_type())) { |
|
146 | 146 | return $item; |
147 | 147 | } |
148 | 148 | |
149 | 149 | $item['method']['last4'] = $payment_token->get_last4(); |
150 | - $item['method']['brand'] = esc_html__( 'SEPA IBAN', 'woocommerce-gateway-stripe' ); |
|
150 | + $item['method']['brand'] = esc_html__('SEPA IBAN', 'woocommerce-gateway-stripe'); |
|
151 | 151 | |
152 | 152 | return $item; |
153 | 153 | } |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | * @since 3.1.0 |
159 | 159 | * @version 4.0.0 |
160 | 160 | */ |
161 | - public function woocommerce_payment_token_deleted( $token_id, $token ) { |
|
162 | - if ( 'stripe' === $token->get_gateway_id() || 'stripe_sepa' === $token->get_gateway_id() ) { |
|
163 | - $stripe_customer = new WC_Stripe_Customer( get_current_user_id() ); |
|
164 | - $stripe_customer->delete_source( $token->get_token() ); |
|
161 | + public function woocommerce_payment_token_deleted($token_id, $token) { |
|
162 | + if ('stripe' === $token->get_gateway_id() || 'stripe_sepa' === $token->get_gateway_id()) { |
|
163 | + $stripe_customer = new WC_Stripe_Customer(get_current_user_id()); |
|
164 | + $stripe_customer->delete_source($token->get_token()); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | * @since 3.1.0 |
172 | 172 | * @version 4.0.0 |
173 | 173 | */ |
174 | - public function woocommerce_payment_token_set_default( $token_id ) { |
|
175 | - $token = WC_Payment_Tokens::get( $token_id ); |
|
174 | + public function woocommerce_payment_token_set_default($token_id) { |
|
175 | + $token = WC_Payment_Tokens::get($token_id); |
|
176 | 176 | |
177 | - if ( 'stripe' === $token->get_gateway_id() || 'stripe_sepa' === $token->get_gateway_id() ) { |
|
178 | - $stripe_customer = new WC_Stripe_Customer( get_current_user_id() ); |
|
179 | - $stripe_customer->set_default_source( $token->get_token() ); |
|
177 | + if ('stripe' === $token->get_gateway_id() || 'stripe_sepa' === $token->get_gateway_id()) { |
|
178 | + $stripe_customer = new WC_Stripe_Customer(get_current_user_id()); |
|
179 | + $stripe_customer->set_default_source($token->get_token()); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -20,23 +20,23 @@ discard block |
||
20 | 20 | * @since 4.0.0 |
21 | 21 | * @version 4.0.0 |
22 | 22 | */ |
23 | - public static function log( $message, $start_time = null, $end_time = null ) { |
|
24 | - if ( empty( self::$logger ) ) { |
|
23 | + public static function log($message, $start_time = null, $end_time = null) { |
|
24 | + if (empty(self::$logger)) { |
|
25 | 25 | self::$logger = new WC_Logger(); |
26 | 26 | } |
27 | 27 | |
28 | - $settings = get_option( 'woocommerce_stripe_settings' ); |
|
28 | + $settings = get_option('woocommerce_stripe_settings'); |
|
29 | 29 | |
30 | - if ( empty( $settings ) || isset( $settings['logging'] ) && 'yes' !== $settings['logging'] ) { |
|
30 | + if (empty($settings) || isset($settings['logging']) && 'yes' !== $settings['logging']) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | - if ( ! is_null( $start_time ) ) { |
|
34 | + if ( ! is_null($start_time)) { |
|
35 | 35 | |
36 | - $formatted_start_time = date_i18n( get_option( 'date_format' ) . ' g:ia', $start_time ); |
|
37 | - $end_time = is_null( $end_time ) ? current_time( 'timestamp' ) : $end_time; |
|
38 | - $formatted_end_time = date_i18n( get_option( 'date_format' ) . ' g:ia', $end_time ); |
|
39 | - $elapsed_time = round( abs( $end_time - $start_time ) / 60, 2 ); |
|
36 | + $formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time); |
|
37 | + $end_time = is_null($end_time) ? current_time('timestamp') : $end_time; |
|
38 | + $formatted_end_time = date_i18n(get_option('date_format') . ' g:ia', $end_time); |
|
39 | + $elapsed_time = round(abs($end_time - $start_time) / 60, 2); |
|
40 | 40 | |
41 | 41 | $log_entry = '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n"; |
42 | 42 | $log_entry .= '====End Log ' . $formatted_end_time . ' (' . $elapsed_time . ')====' . "\n\n"; |
@@ -47,6 +47,6 @@ discard block |
||
47 | 47 | |
48 | 48 | } |
49 | 49 | |
50 | - self::$logger->add( self::WC_LOG_FILENAME, $log_entry ); |
|
50 | + self::$logger->add(self::WC_LOG_FILENAME, $log_entry); |
|
51 | 51 | } |
52 | 52 | } |
@@ -1,50 +1,50 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | 6 | $webhook_url = WC_Stripe_Helper::get_webhook_url(); |
7 | 7 | |
8 | -return apply_filters( 'wc_stripe_bitcoin_settings', |
|
8 | +return apply_filters('wc_stripe_bitcoin_settings', |
|
9 | 9 | array( |
10 | 10 | 'geo_target' => array( |
11 | - 'description' => __( 'Relevant Payer Geography: Global', 'woocommerce-gateway-stripe' ), |
|
11 | + 'description' => __('Relevant Payer Geography: Global', 'woocommerce-gateway-stripe'), |
|
12 | 12 | 'type' => 'title', |
13 | 13 | ), |
14 | 14 | 'guide' => array( |
15 | - 'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#bitcoin" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ), |
|
15 | + 'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#bitcoin" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'), |
|
16 | 16 | 'type' => 'title', |
17 | 17 | ), |
18 | 18 | 'activation' => array( |
19 | - 'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ), |
|
19 | + 'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'), |
|
20 | 20 | 'type' => 'title', |
21 | 21 | ), |
22 | 22 | 'enabled' => array( |
23 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
24 | - 'label' => __( 'Enable Stripe Bitcoin', 'woocommerce-gateway-stripe' ), |
|
23 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
24 | + 'label' => __('Enable Stripe Bitcoin', 'woocommerce-gateway-stripe'), |
|
25 | 25 | 'type' => 'checkbox', |
26 | 26 | 'description' => '', |
27 | 27 | 'default' => 'no', |
28 | 28 | ), |
29 | 29 | 'title' => array( |
30 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
30 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
31 | 31 | 'type' => 'text', |
32 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
33 | - 'default' => __( 'Bitcoin', 'woocommerce-gateway-stripe' ), |
|
32 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
33 | + 'default' => __('Bitcoin', 'woocommerce-gateway-stripe'), |
|
34 | 34 | 'desc_tip' => true, |
35 | 35 | ), |
36 | 36 | 'description' => array( |
37 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
37 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
38 | 38 | 'type' => 'text', |
39 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
40 | - 'default' => __( 'Bitcoin payment information will be provided when you place the order.', 'woocommerce-gateway-stripe' ), |
|
39 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
40 | + 'default' => __('Bitcoin payment information will be provided when you place the order.', 'woocommerce-gateway-stripe'), |
|
41 | 41 | 'desc_tip' => true, |
42 | 42 | ), |
43 | 43 | 'webhook' => array( |
44 | - 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), |
|
44 | + 'title' => __('Webhook Endpoints', 'woocommerce-gateway-stripe'), |
|
45 | 45 | 'type' => 'title', |
46 | 46 | /* translators: webhook URL */ |
47 | - 'description' => sprintf( __( 'You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), $webhook_url ), |
|
47 | + 'description' => sprintf(__('You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), $webhook_url), |
|
48 | 48 | ), |
49 | 49 | ) |
50 | 50 | ); |
@@ -1,50 +1,50 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | 6 | $webhook_url = WC_Stripe_Helper::get_webhook_url(); |
7 | 7 | |
8 | -return apply_filters( 'wc_stripe_ideal_settings', |
|
8 | +return apply_filters('wc_stripe_ideal_settings', |
|
9 | 9 | array( |
10 | 10 | 'geo_target' => array( |
11 | - 'description' => __( 'Relevant Payer Geography: The Netherlands', 'woocommerce-gateway-stripe' ), |
|
11 | + 'description' => __('Relevant Payer Geography: The Netherlands', 'woocommerce-gateway-stripe'), |
|
12 | 12 | 'type' => 'title', |
13 | 13 | ), |
14 | 14 | 'guide' => array( |
15 | - 'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#ideal" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ), |
|
15 | + 'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#ideal" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'), |
|
16 | 16 | 'type' => 'title', |
17 | 17 | ), |
18 | 18 | 'activation' => array( |
19 | - 'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ), |
|
19 | + 'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'), |
|
20 | 20 | 'type' => 'title', |
21 | 21 | ), |
22 | 22 | 'enabled' => array( |
23 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
24 | - 'label' => __( 'Enable Stripe iDeal', 'woocommerce-gateway-stripe' ), |
|
23 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
24 | + 'label' => __('Enable Stripe iDeal', 'woocommerce-gateway-stripe'), |
|
25 | 25 | 'type' => 'checkbox', |
26 | 26 | 'description' => '', |
27 | 27 | 'default' => 'no', |
28 | 28 | ), |
29 | 29 | 'title' => array( |
30 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
30 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
31 | 31 | 'type' => 'text', |
32 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
33 | - 'default' => __( 'iDeal', 'woocommerce-gateway-stripe' ), |
|
32 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
33 | + 'default' => __('iDeal', 'woocommerce-gateway-stripe'), |
|
34 | 34 | 'desc_tip' => true, |
35 | 35 | ), |
36 | 36 | 'description' => array( |
37 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
37 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
38 | 38 | 'type' => 'text', |
39 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
40 | - 'default' => __( 'You will be redirected to iDeal.', 'woocommerce-gateway-stripe' ), |
|
39 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
40 | + 'default' => __('You will be redirected to iDeal.', 'woocommerce-gateway-stripe'), |
|
41 | 41 | 'desc_tip' => true, |
42 | 42 | ), |
43 | 43 | 'webhook' => array( |
44 | - 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), |
|
44 | + 'title' => __('Webhook Endpoints', 'woocommerce-gateway-stripe'), |
|
45 | 45 | 'type' => 'title', |
46 | 46 | /* translators: webhook URL */ |
47 | - 'description' => sprintf( __( 'You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), $webhook_url ), |
|
47 | + 'description' => sprintf(__('You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), $webhook_url), |
|
48 | 48 | ), |
49 | 49 | ) |
50 | 50 | ); |
@@ -1,50 +1,50 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | 6 | $webhook_url = WC_Stripe_Helper::get_webhook_url(); |
7 | 7 | |
8 | -return apply_filters( 'wc_stripe_sofort_settings', |
|
8 | +return apply_filters('wc_stripe_sofort_settings', |
|
9 | 9 | array( |
10 | 10 | 'geo_target' => array( |
11 | - 'description' => __( 'Relevant Payer Geography: Germany, Austria', 'woocommerce-gateway-stripe' ), |
|
11 | + 'description' => __('Relevant Payer Geography: Germany, Austria', 'woocommerce-gateway-stripe'), |
|
12 | 12 | 'type' => 'title', |
13 | 13 | ), |
14 | 14 | 'guide' => array( |
15 | - 'description' => __( '<a href="https://stripe.com/payments/payment-methods-guide#sofort" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe' ), |
|
15 | + 'description' => __('<a href="https://stripe.com/payments/payment-methods-guide#sofort" target="_blank">Payment Method Guide</a>', 'woocommerce-gateway-stripe'), |
|
16 | 16 | 'type' => 'title', |
17 | 17 | ), |
18 | 18 | 'activation' => array( |
19 | - 'description' => __( 'Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe' ), |
|
19 | + 'description' => __('Must be activated from your Stripe Dashboard Settings <a href="https://dashboard.stripe.com/account/payments/settings" target="_blank">here</a>', 'woocommerce-gateway-stripe'), |
|
20 | 20 | 'type' => 'title', |
21 | 21 | ), |
22 | 22 | 'enabled' => array( |
23 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
24 | - 'label' => __( 'Enable Stripe SOFORT', 'woocommerce-gateway-stripe' ), |
|
23 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
24 | + 'label' => __('Enable Stripe SOFORT', 'woocommerce-gateway-stripe'), |
|
25 | 25 | 'type' => 'checkbox', |
26 | 26 | 'description' => '', |
27 | 27 | 'default' => 'no', |
28 | 28 | ), |
29 | 29 | 'title' => array( |
30 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
30 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
31 | 31 | 'type' => 'text', |
32 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
33 | - 'default' => __( 'SOFORT', 'woocommerce-gateway-stripe' ), |
|
32 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
33 | + 'default' => __('SOFORT', 'woocommerce-gateway-stripe'), |
|
34 | 34 | 'desc_tip' => true, |
35 | 35 | ), |
36 | 36 | 'description' => array( |
37 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
37 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
38 | 38 | 'type' => 'text', |
39 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
40 | - 'default' => __( 'You will be redirected to SOFORT.', 'woocommerce-gateway-stripe' ), |
|
39 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
40 | + 'default' => __('You will be redirected to SOFORT.', 'woocommerce-gateway-stripe'), |
|
41 | 41 | 'desc_tip' => true, |
42 | 42 | ), |
43 | 43 | 'webhook' => array( |
44 | - 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), |
|
44 | + 'title' => __('Webhook Endpoints', 'woocommerce-gateway-stripe'), |
|
45 | 45 | 'type' => 'title', |
46 | 46 | /* translators: webhook URL */ |
47 | - 'description' => sprintf( __( 'You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe' ), $webhook_url ), |
|
47 | + 'description' => sprintf(__('You must add the webhook endpoint <strong style="background-color:#ddd;"> %s </strong> to your Stripe Account Settings <a href="https://dashboard.stripe.com/account/webhooks" target="_blank">Here</a> so you can receive notifications on the charge statuses.', 'woocommerce-gateway-stripe'), $webhook_url), |
|
48 | 48 | ), |
49 | 49 | ) |
50 | 50 | ); |