@@ -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 | 22 | /** |
23 | 23 | * Required minimums and constants |
24 | 24 | */ |
25 | -define( 'WC_STRIPE_VERSION', '4.8.0' ); // WRCS: DEFINED_VERSION. |
|
26 | -define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' ); |
|
27 | -define( 'WC_STRIPE_MIN_WC_VER', '3.0' ); |
|
28 | -define( 'WC_STRIPE_FUTURE_MIN_WC_VER', '3.3' ); |
|
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__ ) ) ); |
|
25 | +define('WC_STRIPE_VERSION', '4.8.0'); // WRCS: DEFINED_VERSION. |
|
26 | +define('WC_STRIPE_MIN_PHP_VER', '5.6.0'); |
|
27 | +define('WC_STRIPE_MIN_WC_VER', '3.0'); |
|
28 | +define('WC_STRIPE_FUTURE_MIN_WC_VER', '3.3'); |
|
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 | // phpcs:disable WordPress.Files.FileName |
34 | 34 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function woocommerce_stripe_missing_wc_notice() { |
42 | 42 | /* translators: 1. URL link. */ |
43 | - echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>'; |
|
43 | + echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-gateway-stripe'), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>') . '</strong></p></div>'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function woocommerce_stripe_wc_not_supported() { |
53 | 53 | /* translators: $1. Minimum WooCommerce version. $2. Current WooCommerce version. */ |
54 | - echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'Stripe requires WooCommerce %1$s or greater to be installed and active. WooCommerce %2$s is no longer supported.', 'woocommerce-gateway-stripe' ), WC_STRIPE_MIN_WC_VER, WC_VERSION ) . '</strong></p></div>'; |
|
54 | + echo '<div class="error"><p><strong>' . sprintf(esc_html__('Stripe requires WooCommerce %1$s or greater to be installed and active. WooCommerce %2$s is no longer supported.', 'woocommerce-gateway-stripe'), WC_STRIPE_MIN_WC_VER, WC_VERSION) . '</strong></p></div>'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | function woocommerce_gateway_stripe() { |
58 | 58 | |
59 | 59 | static $plugin; |
60 | 60 | |
61 | - if ( ! isset( $plugin ) ) { |
|
61 | + if ( ! isset($plugin)) { |
|
62 | 62 | |
63 | 63 | class WC_Stripe { |
64 | 64 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return Singleton The *Singleton* instance. |
74 | 74 | */ |
75 | 75 | public static function get_instance() { |
76 | - if ( null === self::$instance ) { |
|
76 | + if (null === self::$instance) { |
|
77 | 77 | self::$instance = new self(); |
78 | 78 | } |
79 | 79 | return self::$instance; |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * *Singleton* via the `new` operator from outside of this class. |
115 | 115 | */ |
116 | 116 | public function __construct() { |
117 | - add_action( 'admin_init', array( $this, 'install' ) ); |
|
117 | + add_action('admin_init', array($this, 'install')); |
|
118 | 118 | |
119 | 119 | $this->init(); |
120 | 120 | |
121 | 121 | $this->api = new WC_Stripe_Connect_API(); |
122 | - $this->connect = new WC_Stripe_Connect( $this->api ); |
|
122 | + $this->connect = new WC_Stripe_Connect($this->api); |
|
123 | 123 | |
124 | - add_action( 'rest_api_init', array( $this, 'register_connect_routes' ) ); |
|
124 | + add_action('rest_api_init', array($this, 'register_connect_routes')); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,57 +131,57 @@ discard block |
||
131 | 131 | * @version 4.0.0 |
132 | 132 | */ |
133 | 133 | public function init() { |
134 | - if ( is_admin() ) { |
|
135 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
134 | + if (is_admin()) { |
|
135 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
136 | 136 | } |
137 | 137 | |
138 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php'; |
|
139 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php'; |
|
140 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php'; |
|
141 | - include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php'; |
|
142 | - require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
143 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
144 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
145 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
146 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
147 | - require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php'; |
|
148 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
149 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
150 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
151 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
152 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
153 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
154 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
155 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
156 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
157 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
158 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
159 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
160 | - require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect.php'; |
|
161 | - require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect-api.php'; |
|
162 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php'; |
|
163 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
164 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php'; |
|
165 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php'; |
|
166 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-inbox-notes.php'; |
|
167 | - |
|
168 | - if ( is_admin() ) { |
|
169 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
138 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php'; |
|
139 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'; |
|
140 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'; |
|
141 | + include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php'; |
|
142 | + require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
143 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
144 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
145 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
146 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
147 | + require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'; |
|
148 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
149 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
150 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
151 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
152 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
153 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
154 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
155 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
156 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
157 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
158 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
159 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
160 | + require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect.php'; |
|
161 | + require_once dirname(__FILE__) . '/includes/connect/class-wc-stripe-connect-api.php'; |
|
162 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'; |
|
163 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
164 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'; |
|
165 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php'; |
|
166 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-inbox-notes.php'; |
|
167 | + |
|
168 | + if (is_admin()) { |
|
169 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // REMOVE IN THE FUTURE. |
173 | - require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
173 | + require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
174 | 174 | |
175 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
176 | - add_filter( 'pre_update_option_woocommerce_stripe_settings', array( $this, 'gateway_settings_update' ), 10, 2 ); |
|
177 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
178 | - add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 ); |
|
175 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
176 | + add_filter('pre_update_option_woocommerce_stripe_settings', array($this, 'gateway_settings_update'), 10, 2); |
|
177 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
178 | + add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2); |
|
179 | 179 | |
180 | 180 | // Modify emails emails. |
181 | - add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 ); |
|
181 | + add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20); |
|
182 | 182 | |
183 | - if ( version_compare( WC_VERSION, '3.4', '<' ) ) { |
|
184 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
183 | + if (version_compare(WC_VERSION, '3.4', '<')) { |
|
184 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @version 4.0.0 |
193 | 193 | */ |
194 | 194 | public function update_plugin_version() { |
195 | - delete_option( 'wc_stripe_version' ); |
|
196 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
195 | + delete_option('wc_stripe_version'); |
|
196 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -203,15 +203,15 @@ discard block |
||
203 | 203 | * @version 3.1.0 |
204 | 204 | */ |
205 | 205 | public function install() { |
206 | - if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
206 | + if ( ! is_plugin_active(plugin_basename(__FILE__))) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
211 | - do_action( 'woocommerce_stripe_updated' ); |
|
210 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
211 | + do_action('woocommerce_stripe_updated'); |
|
212 | 212 | |
213 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
214 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
213 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
214 | + define('WC_STRIPE_INSTALLING', true); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | $this->update_plugin_version(); |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | * @since 1.0.0 |
225 | 225 | * @version 4.0.0 |
226 | 226 | */ |
227 | - public function plugin_action_links( $links ) { |
|
227 | + public function plugin_action_links($links) { |
|
228 | 228 | $plugin_links = array( |
229 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
229 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
230 | 230 | ); |
231 | - return array_merge( $plugin_links, $links ); |
|
231 | + return array_merge($plugin_links, $links); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | * @param string $file Name of current file. |
240 | 240 | * @return array $links Update list of plugin links. |
241 | 241 | */ |
242 | - public function plugin_row_meta( $links, $file ) { |
|
243 | - if ( plugin_basename( __FILE__ ) === $file ) { |
|
242 | + public function plugin_row_meta($links, $file) { |
|
243 | + if (plugin_basename(__FILE__) === $file) { |
|
244 | 244 | $row_meta = array( |
245 | - 'docs' => '<a href="' . esc_url( apply_filters( 'woocommerce_gateway_stripe_docs_url', 'https://docs.woocommerce.com/document/stripe/' ) ) . '" title="' . esc_attr( __( 'View Documentation', 'woocommerce-gateway-stripe' ) ) . '">' . __( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>', |
|
246 | - 'support' => '<a href="' . esc_url( apply_filters( 'woocommerce_gateway_stripe_support_url', 'https://woocommerce.com/my-account/create-a-ticket?select=18627' ) ) . '" title="' . esc_attr( __( 'Open a support request at WooCommerce.com', 'woocommerce-gateway-stripe' ) ) . '">' . __( 'Support', 'woocommerce-gateway-stripe' ) . '</a>', |
|
245 | + 'docs' => '<a href="' . esc_url(apply_filters('woocommerce_gateway_stripe_docs_url', 'https://docs.woocommerce.com/document/stripe/')) . '" title="' . esc_attr(__('View Documentation', 'woocommerce-gateway-stripe')) . '">' . __('Docs', 'woocommerce-gateway-stripe') . '</a>', |
|
246 | + 'support' => '<a href="' . esc_url(apply_filters('woocommerce_gateway_stripe_support_url', 'https://woocommerce.com/my-account/create-a-ticket?select=18627')) . '" title="' . esc_attr(__('Open a support request at WooCommerce.com', 'woocommerce-gateway-stripe')) . '">' . __('Support', 'woocommerce-gateway-stripe') . '</a>', |
|
247 | 247 | ); |
248 | - return array_merge( $links, $row_meta ); |
|
248 | + return array_merge($links, $row_meta); |
|
249 | 249 | } |
250 | 250 | return (array) $links; |
251 | 251 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | * @since 1.0.0 |
257 | 257 | * @version 4.0.0 |
258 | 258 | */ |
259 | - public function add_gateways( $methods ) { |
|
260 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) { |
|
259 | + public function add_gateways($methods) { |
|
260 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) { |
|
261 | 261 | $methods[] = 'WC_Stripe_Subs_Compat'; |
262 | 262 | $methods[] = 'WC_Stripe_Sepa_Subs_Compat'; |
263 | 263 | } else { |
@@ -283,28 +283,28 @@ discard block |
||
283 | 283 | * @since 4.0.0 |
284 | 284 | * @version 4.0.0 |
285 | 285 | */ |
286 | - public function filter_gateway_order_admin( $sections ) { |
|
287 | - unset( $sections['stripe'] ); |
|
288 | - unset( $sections['stripe_bancontact'] ); |
|
289 | - unset( $sections['stripe_sofort'] ); |
|
290 | - unset( $sections['stripe_giropay'] ); |
|
291 | - unset( $sections['stripe_eps'] ); |
|
292 | - unset( $sections['stripe_ideal'] ); |
|
293 | - unset( $sections['stripe_p24'] ); |
|
294 | - unset( $sections['stripe_alipay'] ); |
|
295 | - unset( $sections['stripe_sepa'] ); |
|
296 | - unset( $sections['stripe_multibanco'] ); |
|
286 | + public function filter_gateway_order_admin($sections) { |
|
287 | + unset($sections['stripe']); |
|
288 | + unset($sections['stripe_bancontact']); |
|
289 | + unset($sections['stripe_sofort']); |
|
290 | + unset($sections['stripe_giropay']); |
|
291 | + unset($sections['stripe_eps']); |
|
292 | + unset($sections['stripe_ideal']); |
|
293 | + unset($sections['stripe_p24']); |
|
294 | + unset($sections['stripe_alipay']); |
|
295 | + unset($sections['stripe_sepa']); |
|
296 | + unset($sections['stripe_multibanco']); |
|
297 | 297 | |
298 | 298 | $sections['stripe'] = 'Stripe'; |
299 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
300 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
301 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
302 | - $sections['stripe_eps'] = __( 'Stripe EPS', 'woocommerce-gateway-stripe' ); |
|
303 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
304 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
305 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
306 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
307 | - $sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' ); |
|
299 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
300 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
301 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
302 | + $sections['stripe_eps'] = __('Stripe EPS', 'woocommerce-gateway-stripe'); |
|
303 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
304 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
305 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
306 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
307 | + $sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe'); |
|
308 | 308 | |
309 | 309 | return $sections; |
310 | 310 | } |
@@ -319,12 +319,12 @@ discard block |
||
319 | 319 | * @param array|bool $old_settings Existing settings, if any. |
320 | 320 | * @return array New value but with defaults initially filled in for missing settings. |
321 | 321 | */ |
322 | - public function gateway_settings_update( $settings, $old_settings ) { |
|
323 | - if ( false === $old_settings ) { |
|
322 | + public function gateway_settings_update($settings, $old_settings) { |
|
323 | + if (false === $old_settings) { |
|
324 | 324 | $gateway = new WC_Gateway_Stripe(); |
325 | 325 | $fields = $gateway->get_form_fields(); |
326 | - $defaults = array_merge( array_fill_keys( array_keys( $fields ), '' ), wp_list_pluck( $fields, 'default' ) ); |
|
327 | - return array_merge( $defaults, $settings ); |
|
326 | + $defaults = array_merge(array_fill_keys(array_keys($fields), ''), wp_list_pluck($fields, 'default')); |
|
327 | + return array_merge($defaults, $settings); |
|
328 | 328 | } |
329 | 329 | return $settings; |
330 | 330 | } |
@@ -335,16 +335,16 @@ discard block |
||
335 | 335 | * @param WC_Email[] $email_classes All existing emails. |
336 | 336 | * @return WC_Email[] |
337 | 337 | */ |
338 | - public function add_emails( $email_classes ) { |
|
338 | + public function add_emails($email_classes) { |
|
339 | 339 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php'; |
340 | 340 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php'; |
341 | 341 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php'; |
342 | 342 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication-retry.php'; |
343 | 343 | |
344 | 344 | // Add all emails, generated by the gateway. |
345 | - $email_classes['WC_Stripe_Email_Failed_Renewal_Authentication'] = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes ); |
|
346 | - $email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes ); |
|
347 | - $email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry( $email_classes ); |
|
345 | + $email_classes['WC_Stripe_Email_Failed_Renewal_Authentication'] = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes); |
|
346 | + $email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes); |
|
347 | + $email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry($email_classes); |
|
348 | 348 | |
349 | 349 | return $email_classes; |
350 | 350 | } |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-init-controller.php'; |
359 | 359 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/connect/class-wc-stripe-connect-rest-oauth-connect-controller.php'; |
360 | 360 | |
361 | - $oauth_init = new WC_Stripe_Connect_REST_Oauth_Init_Controller( $this->connect, $this->api ); |
|
362 | - $oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller( $this->connect, $this->api ); |
|
361 | + $oauth_init = new WC_Stripe_Connect_REST_Oauth_Init_Controller($this->connect, $this->api); |
|
362 | + $oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller($this->connect, $this->api); |
|
363 | 363 | |
364 | 364 | $oauth_init->register_routes(); |
365 | 365 | $oauth_connect->register_routes(); |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | return $plugin; |
374 | 374 | } |
375 | 375 | |
376 | -add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' ); |
|
376 | +add_action('plugins_loaded', 'woocommerce_gateway_stripe_init'); |
|
377 | 377 | |
378 | 378 | function woocommerce_gateway_stripe_init() { |
379 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
379 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
380 | 380 | |
381 | - if ( ! class_exists( 'WooCommerce' ) ) { |
|
382 | - add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' ); |
|
381 | + if ( ! class_exists('WooCommerce')) { |
|
382 | + add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice'); |
|
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
387 | - add_action( 'admin_notices', 'woocommerce_stripe_wc_not_supported' ); |
|
386 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
387 | + add_action('admin_notices', 'woocommerce_stripe_wc_not_supported'); |
|
388 | 388 | return; |
389 | 389 | } |
390 | 390 |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | |
3 | 3 | class WC_Stripe_Test extends WP_UnitTestCase { |
4 | 4 | public function test_constants_defined() { |
5 | - $this->assertTrue( defined( 'WC_STRIPE_VERSION' ) ); |
|
6 | - $this->assertTrue( defined( 'WC_STRIPE_MIN_PHP_VER' ) ); |
|
7 | - $this->assertTrue( defined( 'WC_STRIPE_MIN_WC_VER' ) ); |
|
8 | - $this->assertTrue( defined( 'WC_STRIPE_MAIN_FILE' ) ); |
|
9 | - $this->assertTrue( defined( 'WC_STRIPE_PLUGIN_URL' ) ); |
|
10 | - $this->assertTrue( defined( 'WC_STRIPE_PLUGIN_PATH' ) ); |
|
5 | + $this->assertTrue(defined('WC_STRIPE_VERSION')); |
|
6 | + $this->assertTrue(defined('WC_STRIPE_MIN_PHP_VER')); |
|
7 | + $this->assertTrue(defined('WC_STRIPE_MIN_WC_VER')); |
|
8 | + $this->assertTrue(defined('WC_STRIPE_MAIN_FILE')); |
|
9 | + $this->assertTrue(defined('WC_STRIPE_PLUGIN_URL')); |
|
10 | + $this->assertTrue(defined('WC_STRIPE_PLUGIN_PATH')); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * This test will see if we're indeed converting the price correctly. |
16 | 16 | */ |
17 | 17 | public function test_price_conversion_before_send_to_stripe() { |
18 | - $this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 100.50, 'USD' ) ); |
|
19 | - $this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 10050, 'JPY' ) ); |
|
20 | - $this->assertEquals( 100, WC_Stripe_Helper::get_stripe_amount( 100.50, 'JPY' ) ); |
|
21 | - $this->assertEquals( 10050, WC_Stripe_Helper::get_stripe_amount( 100.50 ) ); |
|
22 | - $this->assertInternalType( 'int', WC_Stripe_Helper::get_stripe_amount( 100.50, 'USD' ) ); |
|
18 | + $this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(100.50, 'USD')); |
|
19 | + $this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(10050, 'JPY')); |
|
20 | + $this->assertEquals(100, WC_Stripe_Helper::get_stripe_amount(100.50, 'JPY')); |
|
21 | + $this->assertEquals(10050, WC_Stripe_Helper::get_stripe_amount(100.50)); |
|
22 | + $this->assertInternalType('int', WC_Stripe_Helper::get_stripe_amount(100.50, 'USD')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -33,37 +33,37 @@ discard block |
||
33 | 33 | $balance_fee1->net = 10000; |
34 | 34 | $balance_fee1->currency = 'USD'; |
35 | 35 | |
36 | - $this->assertEquals( 105.00, WC_Stripe_Helper::format_balance_fee( $balance_fee1, 'fee' ) ); |
|
36 | + $this->assertEquals(105.00, WC_Stripe_Helper::format_balance_fee($balance_fee1, 'fee')); |
|
37 | 37 | |
38 | 38 | $balance_fee2 = new stdClass(); |
39 | 39 | $balance_fee2->fee = 10500; |
40 | 40 | $balance_fee2->net = 10000; |
41 | 41 | $balance_fee2->currency = 'JPY'; |
42 | 42 | |
43 | - $this->assertEquals( 10500, WC_Stripe_Helper::format_balance_fee( $balance_fee2, 'fee' ) ); |
|
43 | + $this->assertEquals(10500, WC_Stripe_Helper::format_balance_fee($balance_fee2, 'fee')); |
|
44 | 44 | |
45 | 45 | $balance_fee3 = new stdClass(); |
46 | 46 | $balance_fee3->fee = 10500; |
47 | 47 | $balance_fee3->net = 10000; |
48 | 48 | $balance_fee3->currency = 'USD'; |
49 | 49 | |
50 | - $this->assertEquals( 100.00, WC_Stripe_Helper::format_balance_fee( $balance_fee3, 'net' ) ); |
|
50 | + $this->assertEquals(100.00, WC_Stripe_Helper::format_balance_fee($balance_fee3, 'net')); |
|
51 | 51 | |
52 | 52 | $balance_fee4 = new stdClass(); |
53 | 53 | $balance_fee4->fee = 10500; |
54 | 54 | $balance_fee4->net = 10000; |
55 | 55 | $balance_fee4->currency = 'JPY'; |
56 | 56 | |
57 | - $this->assertEquals( 10000, WC_Stripe_Helper::format_balance_fee( $balance_fee4, 'net' ) ); |
|
57 | + $this->assertEquals(10000, WC_Stripe_Helper::format_balance_fee($balance_fee4, 'net')); |
|
58 | 58 | |
59 | 59 | $balance_fee5 = new stdClass(); |
60 | 60 | $balance_fee5->fee = 10500; |
61 | 61 | $balance_fee5->net = 10000; |
62 | 62 | $balance_fee5->currency = 'USD'; |
63 | 63 | |
64 | - $this->assertEquals( 105.00, WC_Stripe_Helper::format_balance_fee( $balance_fee5 ) ); |
|
64 | + $this->assertEquals(105.00, WC_Stripe_Helper::format_balance_fee($balance_fee5)); |
|
65 | 65 | |
66 | - $this->assertInternalType( 'string', WC_Stripe_Helper::format_balance_fee( $balance_fee5 ) ); |
|
66 | + $this->assertInternalType('string', WC_Stripe_Helper::format_balance_fee($balance_fee5)); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -72,27 +72,27 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @dataProvider statement_descriptor_sanitation_provider |
74 | 74 | */ |
75 | - public function test_statement_descriptor_sanitation( $original, $expected ) { |
|
76 | - $this->assertEquals( $expected, WC_Stripe_Helper::clean_statement_descriptor( $original ) ); |
|
75 | + public function test_statement_descriptor_sanitation($original, $expected) { |
|
76 | + $this->assertEquals($expected, WC_Stripe_Helper::clean_statement_descriptor($original)); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | public function statement_descriptor_sanitation_provider() { |
80 | 80 | return [ |
81 | - 'removes \'' => [ 'Test\'s Store', 'Tests Store' ], |
|
82 | - 'removes "' => [ 'Test " Store', 'Test Store' ], |
|
83 | - 'removes <' => [ 'Test < Store', 'Test Store' ], |
|
84 | - 'removes >' => [ 'Test > Store', 'Test Store' ], |
|
85 | - 'removes /' => [ 'Test / Store', 'Test Store' ], |
|
86 | - 'removes (' => [ 'Test ( Store', 'Test Store' ], |
|
87 | - 'removes )' => [ 'Test ) Store', 'Test Store' ], |
|
88 | - 'removes {' => [ 'Test { Store', 'Test Store' ], |
|
89 | - 'removes }' => [ 'Test } Store', 'Test Store' ], |
|
90 | - 'removes \\' => [ 'Test \\ Store', 'Test Store' ], |
|
91 | - 'removes *' => [ 'Test * Store', 'Test Store' ], |
|
92 | - 'keeps at most 22 chars' => [ 'Test\'s Store > Driving Course Range', 'Tests Store Driving C' ], |
|
93 | - 'mixed length, \' and >' => [ 'Test\'s Store > Driving Course Range', 'Tests Store Driving C' ], |
|
94 | - 'mixed length, \' and <' => [ 'Test\'s Store < Driving Course Range', 'Tests Store Driving C' ], |
|
95 | - 'mixed length, \' and "' => [ 'Test\'s Store " Driving Course Range', 'Tests Store Driving C' ] |
|
81 | + 'removes \'' => ['Test\'s Store', 'Tests Store'], |
|
82 | + 'removes "' => ['Test " Store', 'Test Store'], |
|
83 | + 'removes <' => ['Test < Store', 'Test Store'], |
|
84 | + 'removes >' => ['Test > Store', 'Test Store'], |
|
85 | + 'removes /' => ['Test / Store', 'Test Store'], |
|
86 | + 'removes (' => ['Test ( Store', 'Test Store'], |
|
87 | + 'removes )' => ['Test ) Store', 'Test Store'], |
|
88 | + 'removes {' => ['Test { Store', 'Test Store'], |
|
89 | + 'removes }' => ['Test } Store', 'Test Store'], |
|
90 | + 'removes \\' => ['Test \\ Store', 'Test Store'], |
|
91 | + 'removes *' => ['Test * Store', 'Test Store'], |
|
92 | + 'keeps at most 22 chars' => ['Test\'s Store > Driving Course Range', 'Tests Store Driving C'], |
|
93 | + 'mixed length, \' and >' => ['Test\'s Store > Driving Course Range', 'Tests Store Driving C'], |
|
94 | + 'mixed length, \' and <' => ['Test\'s Store < Driving Course Range', 'Tests Store Driving C'], |
|
95 | + 'mixed length, \' and "' => ['Test\'s Store " Driving Course Range', 'Tests Store Driving C'] |
|
96 | 96 | ]; |
97 | 97 | } |
98 | 98 | } |
@@ -1,28 +1,28 @@ |
||
1 | 1 | <?php |
2 | -$_tests_dir = getenv( 'WP_TESTS_DIR' ); |
|
3 | -if ( ! $_tests_dir ) { |
|
2 | +$_tests_dir = getenv('WP_TESTS_DIR'); |
|
3 | +if ( ! $_tests_dir) { |
|
4 | 4 | $_tests_dir = '/tmp/wordpress-tests-lib'; |
5 | 5 | } |
6 | 6 | |
7 | 7 | require_once $_tests_dir . '/includes/functions.php'; |
8 | 8 | |
9 | 9 | function _manually_load_plugin() { |
10 | - $plugin_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/'; |
|
10 | + $plugin_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/'; |
|
11 | 11 | require $plugin_dir . 'woocommerce/woocommerce.php'; |
12 | - require dirname( __FILE__ ) . '/setup.php'; |
|
12 | + require dirname(__FILE__) . '/setup.php'; |
|
13 | 13 | require $plugin_dir . 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php'; |
14 | 14 | } |
15 | 15 | |
16 | -tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); |
|
16 | +tests_add_filter('muplugins_loaded', '_manually_load_plugin'); |
|
17 | 17 | |
18 | 18 | require $_tests_dir . '/includes/bootstrap.php'; |
19 | 19 | |
20 | -$wc_tests_framework_base_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/woocommerce/tests/legacy/framework/'; |
|
21 | -require_once( $wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php' ); |
|
20 | +$wc_tests_framework_base_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/woocommerce/tests/legacy/framework/'; |
|
21 | +require_once($wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php'); |
|
22 | 22 | //require_once( $wc_tests_framework_base_dir . 'class-wc-unit-test-case.php' ); |
23 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php' ); |
|
24 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php' ); |
|
25 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php' ); |
|
26 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php' ); |
|
27 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php' ); |
|
28 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php' ); |
|
23 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php'); |
|
24 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php'); |
|
25 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php'); |
|
26 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php'); |
|
27 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php'); |
|
28 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php'); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct() { |
41 | 41 | $this->retry_interval = 2; |
42 | - $stripe_settings = get_option( 'woocommerce_stripe_settings', array() ); |
|
43 | - $this->testmode = ( ! empty( $stripe_settings['testmode'] ) && 'yes' === $stripe_settings['testmode'] ) ? true : false; |
|
44 | - $secret_key = ( $this->testmode ? 'test_' : '' ) . 'webhook_secret'; |
|
45 | - $this->secret = ! empty( $stripe_settings[ $secret_key ] ) ? $stripe_settings[ $secret_key ] : false; |
|
42 | + $stripe_settings = get_option('woocommerce_stripe_settings', array()); |
|
43 | + $this->testmode = ( ! empty($stripe_settings['testmode']) && 'yes' === $stripe_settings['testmode']) ? true : false; |
|
44 | + $secret_key = ($this->testmode ? 'test_' : '') . 'webhook_secret'; |
|
45 | + $this->secret = ! empty($stripe_settings[$secret_key]) ? $stripe_settings[$secret_key] : false; |
|
46 | 46 | |
47 | - add_action( 'woocommerce_api_wc_stripe', array( $this, 'check_for_webhook' ) ); |
|
47 | + add_action('woocommerce_api_wc_stripe', array($this, 'check_for_webhook')); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -54,26 +54,26 @@ discard block |
||
54 | 54 | * @version 4.0.0 |
55 | 55 | */ |
56 | 56 | public function check_for_webhook() { |
57 | - if ( ( 'POST' !== $_SERVER['REQUEST_METHOD'] ) |
|
58 | - || ! isset( $_GET['wc-api'] ) |
|
59 | - || ( 'wc_stripe' !== $_GET['wc-api'] ) |
|
57 | + if (('POST' !== $_SERVER['REQUEST_METHOD']) |
|
58 | + || ! isset($_GET['wc-api']) |
|
59 | + || ('wc_stripe' !== $_GET['wc-api']) |
|
60 | 60 | ) { |
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | - $request_body = file_get_contents( 'php://input' ); |
|
65 | - $request_headers = array_change_key_case( $this->get_request_headers(), CASE_UPPER ); |
|
64 | + $request_body = file_get_contents('php://input'); |
|
65 | + $request_headers = array_change_key_case($this->get_request_headers(), CASE_UPPER); |
|
66 | 66 | |
67 | 67 | // Validate it to make sure it is legit. |
68 | - if ( $this->is_valid_request( $request_headers, $request_body ) ) { |
|
69 | - $this->process_webhook( $request_body ); |
|
70 | - status_header( 200 ); |
|
68 | + if ($this->is_valid_request($request_headers, $request_body)) { |
|
69 | + $this->process_webhook($request_body); |
|
70 | + status_header(200); |
|
71 | 71 | exit; |
72 | 72 | } else { |
73 | - WC_Stripe_Logger::log( 'Incoming webhook failed validation: ' . print_r( $request_body, true ) ); |
|
73 | + WC_Stripe_Logger::log('Incoming webhook failed validation: ' . print_r($request_body, true)); |
|
74 | 74 | // A webhook endpoint must return a 2xx HTTP status code. |
75 | 75 | // @see https://stripe.com/docs/webhooks/build#return-a-2xx-status-code-quickly |
76 | - status_header( 204 ); |
|
76 | + status_header(204); |
|
77 | 77 | exit; |
78 | 78 | } |
79 | 79 | } |
@@ -87,34 +87,34 @@ discard block |
||
87 | 87 | * @param string $request_body The request body from Stripe. |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | - public function is_valid_request( $request_headers = null, $request_body = null ) { |
|
91 | - if ( null === $request_headers || null === $request_body ) { |
|
90 | + public function is_valid_request($request_headers = null, $request_body = null) { |
|
91 | + if (null === $request_headers || null === $request_body) { |
|
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
95 | - if ( ! empty( $request_headers['USER-AGENT'] ) && ! preg_match( '/Stripe/', $request_headers['USER-AGENT'] ) ) { |
|
95 | + if ( ! empty($request_headers['USER-AGENT']) && ! preg_match('/Stripe/', $request_headers['USER-AGENT'])) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if ( ! empty( $this->secret ) ) { |
|
99 | + if ( ! empty($this->secret)) { |
|
100 | 100 | // Check for a valid signature. |
101 | 101 | $signature_format = '/^t=(?P<timestamp>\d+)(?P<signatures>(,v\d+=[a-z0-9]+){1,2})$/'; |
102 | - if ( empty( $request_headers['STRIPE-SIGNATURE'] ) || ! preg_match( $signature_format, $request_headers['STRIPE-SIGNATURE'], $matches ) ) { |
|
102 | + if (empty($request_headers['STRIPE-SIGNATURE']) || ! preg_match($signature_format, $request_headers['STRIPE-SIGNATURE'], $matches)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Verify the timestamp. |
107 | - $timestamp = intval( $matches['timestamp'] ); |
|
108 | - if ( abs( $timestamp - time() ) > 5 * MINUTE_IN_SECONDS ) { |
|
107 | + $timestamp = intval($matches['timestamp']); |
|
108 | + if (abs($timestamp - time()) > 5 * MINUTE_IN_SECONDS) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | 112 | // Generate the expected signature. |
113 | 113 | $signed_payload = $timestamp . '.' . $request_body; |
114 | - $expected_signature = hash_hmac( 'sha256', $signed_payload, $this->secret ); |
|
114 | + $expected_signature = hash_hmac('sha256', $signed_payload, $this->secret); |
|
115 | 115 | |
116 | 116 | // Check if the expected signature is present. |
117 | - if ( ! preg_match( '/,v\d+=' . preg_quote( $expected_signature, '/' ) . '/', $matches['signatures'] ) ) { |
|
117 | + if ( ! preg_match('/,v\d+=' . preg_quote($expected_signature, '/') . '/', $matches['signatures'])) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | } |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | * @version 4.0.0 |
132 | 132 | */ |
133 | 133 | public function get_request_headers() { |
134 | - if ( ! function_exists( 'getallheaders' ) ) { |
|
134 | + if ( ! function_exists('getallheaders')) { |
|
135 | 135 | $headers = array(); |
136 | 136 | |
137 | - foreach ( $_SERVER as $name => $value ) { |
|
138 | - if ( 'HTTP_' === substr( $name, 0, 5 ) ) { |
|
139 | - $headers[ str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value; |
|
137 | + foreach ($_SERVER as $name => $value) { |
|
138 | + if ('HTTP_' === substr($name, 0, 5)) { |
|
139 | + $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -155,30 +155,30 @@ discard block |
||
155 | 155 | * @param object $notification |
156 | 156 | * @param bool $retry |
157 | 157 | */ |
158 | - public function process_webhook_payment( $notification, $retry = true ) { |
|
158 | + public function process_webhook_payment($notification, $retry = true) { |
|
159 | 159 | // The following 3 payment methods are synchronous so does not need to be handle via webhook. |
160 | - if ( 'card' === $notification->data->object->type || 'sepa_debit' === $notification->data->object->type || 'three_d_secure' === $notification->data->object->type ) { |
|
160 | + if ('card' === $notification->data->object->type || 'sepa_debit' === $notification->data->object->type || 'three_d_secure' === $notification->data->object->type) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | - $order = WC_Stripe_Helper::get_order_by_source_id( $notification->data->object->id ); |
|
164 | + $order = WC_Stripe_Helper::get_order_by_source_id($notification->data->object->id); |
|
165 | 165 | |
166 | - if ( ! $order ) { |
|
167 | - WC_Stripe_Logger::log( 'Could not find order via source ID: ' . $notification->data->object->id ); |
|
166 | + if ( ! $order) { |
|
167 | + WC_Stripe_Logger::log('Could not find order via source ID: ' . $notification->data->object->id); |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | 171 | $order_id = $order->get_id(); |
172 | 172 | $source_id = $notification->data->object->id; |
173 | 173 | |
174 | - $is_pending_receiver = ( 'receiver' === $notification->data->object->flow ); |
|
174 | + $is_pending_receiver = ('receiver' === $notification->data->object->flow); |
|
175 | 175 | |
176 | 176 | try { |
177 | - if ( $order->has_status( array( 'processing', 'completed' ) ) ) { |
|
177 | + if ($order->has_status(array('processing', 'completed'))) { |
|
178 | 178 | return; |
179 | 179 | } |
180 | 180 | |
181 | - if ( $order->has_status( 'on-hold' ) && ! $is_pending_receiver ) { |
|
181 | + if ($order->has_status('on-hold') && ! $is_pending_receiver) { |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
@@ -186,89 +186,89 @@ discard block |
||
186 | 186 | $response = null; |
187 | 187 | |
188 | 188 | // This will throw exception if not valid. |
189 | - $this->validate_minimum_order_amount( $order ); |
|
189 | + $this->validate_minimum_order_amount($order); |
|
190 | 190 | |
191 | - WC_Stripe_Logger::log( "Info: (Webhook) Begin processing payment for order $order_id for the amount of {$order->get_total()}" ); |
|
191 | + WC_Stripe_Logger::log("Info: (Webhook) Begin processing payment for order $order_id for the amount of {$order->get_total()}"); |
|
192 | 192 | |
193 | 193 | // Prep source object. |
194 | 194 | $source_object = new stdClass(); |
195 | 195 | $source_object->token_id = ''; |
196 | - $source_object->customer = $this->get_stripe_customer_id( $order ); |
|
196 | + $source_object->customer = $this->get_stripe_customer_id($order); |
|
197 | 197 | $source_object->source = $source_id; |
198 | 198 | |
199 | 199 | // Make the request. |
200 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source_object ), 'charges', 'POST', true ); |
|
200 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $source_object), 'charges', 'POST', true); |
|
201 | 201 | $headers = $response['headers']; |
202 | 202 | $response = $response['body']; |
203 | 203 | |
204 | - if ( ! empty( $response->error ) ) { |
|
204 | + if ( ! empty($response->error)) { |
|
205 | 205 | // Customer param wrong? The user may have been deleted on stripe's end. Remove customer_id. Can be retried without. |
206 | - if ( $this->is_no_such_customer_error( $response->error ) ) { |
|
207 | - delete_user_option( $order->get_customer_id(), '_stripe_customer_id' ); |
|
208 | - $order->delete_meta_data( '_stripe_customer_id' ); |
|
206 | + if ($this->is_no_such_customer_error($response->error)) { |
|
207 | + delete_user_option($order->get_customer_id(), '_stripe_customer_id'); |
|
208 | + $order->delete_meta_data('_stripe_customer_id'); |
|
209 | 209 | $order->save(); |
210 | 210 | } |
211 | 211 | |
212 | - if ( $this->is_no_such_token_error( $response->error ) && $prepared_source->token_id ) { |
|
212 | + if ($this->is_no_such_token_error($response->error) && $prepared_source->token_id) { |
|
213 | 213 | // Source param wrong? The CARD may have been deleted on stripe's end. Remove token and show message. |
214 | - $wc_token = WC_Payment_Tokens::get( $prepared_source->token_id ); |
|
214 | + $wc_token = WC_Payment_Tokens::get($prepared_source->token_id); |
|
215 | 215 | $wc_token->delete(); |
216 | - $localized_message = __( 'This card is no longer available and has been removed.', 'woocommerce-gateway-stripe' ); |
|
217 | - $order->add_order_note( $localized_message ); |
|
218 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
216 | + $localized_message = __('This card is no longer available and has been removed.', 'woocommerce-gateway-stripe'); |
|
217 | + $order->add_order_note($localized_message); |
|
218 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | // We want to retry. |
222 | - if ( $this->is_retryable_error( $response->error ) ) { |
|
223 | - if ( $retry ) { |
|
222 | + if ($this->is_retryable_error($response->error)) { |
|
223 | + if ($retry) { |
|
224 | 224 | // Don't do anymore retries after this. |
225 | - if ( 5 <= $this->retry_interval ) { |
|
225 | + if (5 <= $this->retry_interval) { |
|
226 | 226 | |
227 | - return $this->process_webhook_payment( $notification, false ); |
|
227 | + return $this->process_webhook_payment($notification, false); |
|
228 | 228 | } |
229 | 229 | |
230 | - sleep( $this->retry_interval ); |
|
230 | + sleep($this->retry_interval); |
|
231 | 231 | |
232 | 232 | $this->retry_interval++; |
233 | - return $this->process_webhook_payment( $notification, true ); |
|
233 | + return $this->process_webhook_payment($notification, true); |
|
234 | 234 | } else { |
235 | - $localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' ); |
|
236 | - $order->add_order_note( $localized_message ); |
|
237 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
235 | + $localized_message = __('Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe'); |
|
236 | + $order->add_order_note($localized_message); |
|
237 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | 241 | $localized_messages = WC_Stripe_Helper::get_localized_messages(); |
242 | 242 | |
243 | - if ( 'card_error' === $response->error->type ) { |
|
244 | - $localized_message = isset( $localized_messages[ $response->error->code ] ) ? $localized_messages[ $response->error->code ] : $response->error->message; |
|
243 | + if ('card_error' === $response->error->type) { |
|
244 | + $localized_message = isset($localized_messages[$response->error->code]) ? $localized_messages[$response->error->code] : $response->error->message; |
|
245 | 245 | } else { |
246 | - $localized_message = isset( $localized_messages[ $response->error->type ] ) ? $localized_messages[ $response->error->type ] : $response->error->message; |
|
246 | + $localized_message = isset($localized_messages[$response->error->type]) ? $localized_messages[$response->error->type] : $response->error->message; |
|
247 | 247 | } |
248 | 248 | |
249 | - $order->add_order_note( $localized_message ); |
|
249 | + $order->add_order_note($localized_message); |
|
250 | 250 | |
251 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
251 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | // To prevent double processing the order on WC side. |
255 | - if ( ! $this->is_original_request( $headers ) ) { |
|
255 | + if ( ! $this->is_original_request($headers)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | - do_action( 'wc_gateway_stripe_process_webhook_payment', $response, $order ); |
|
259 | + do_action('wc_gateway_stripe_process_webhook_payment', $response, $order); |
|
260 | 260 | |
261 | - $this->process_response( $response, $order ); |
|
261 | + $this->process_response($response, $order); |
|
262 | 262 | |
263 | - } catch ( WC_Stripe_Exception $e ) { |
|
264 | - WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); |
|
263 | + } catch (WC_Stripe_Exception $e) { |
|
264 | + WC_Stripe_Logger::log('Error: ' . $e->getMessage()); |
|
265 | 265 | |
266 | - do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification, $e ); |
|
266 | + do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification, $e); |
|
267 | 267 | |
268 | - $statuses = array( 'pending', 'failed' ); |
|
268 | + $statuses = array('pending', 'failed'); |
|
269 | 269 | |
270 | - if ( $order->has_status( $statuses ) ) { |
|
271 | - $this->send_failed_order_email( $order_id ); |
|
270 | + if ($order->has_status($statuses)) { |
|
271 | + $this->send_failed_order_email($order_id); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | } |
@@ -281,28 +281,28 @@ discard block |
||
281 | 281 | * @since 4.0.0 |
282 | 282 | * @param object $notification |
283 | 283 | */ |
284 | - public function process_webhook_dispute( $notification ) { |
|
285 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge ); |
|
284 | + public function process_webhook_dispute($notification) { |
|
285 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge); |
|
286 | 286 | |
287 | - if ( ! $order ) { |
|
288 | - WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge ); |
|
287 | + if ( ! $order) { |
|
288 | + WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->charge); |
|
289 | 289 | return; |
290 | 290 | } |
291 | 291 | |
292 | - $order->update_meta_data( '_stripe_status_before_hold', $order->get_status() ); |
|
292 | + $order->update_meta_data('_stripe_status_before_hold', $order->get_status()); |
|
293 | 293 | |
294 | 294 | /* translators: 1) The URL to the order. */ |
295 | - $message = sprintf( __( 'A dispute was created for this order. Response is needed. Please go to your <a href="%s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review this dispute.', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ) ); |
|
296 | - if ( ! $order->get_meta( '_stripe_status_final', false ) ) { |
|
297 | - $order->update_status( 'on-hold', $message ); |
|
295 | + $message = sprintf(__('A dispute was created for this order. Response is needed. Please go to your <a href="%s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review this dispute.', 'woocommerce-gateway-stripe'), $this->get_transaction_url($order)); |
|
296 | + if ( ! $order->get_meta('_stripe_status_final', false)) { |
|
297 | + $order->update_status('on-hold', $message); |
|
298 | 298 | } else { |
299 | - $order->add_order_note( $message ); |
|
299 | + $order->add_order_note($message); |
|
300 | 300 | } |
301 | 301 | |
302 | - do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification ); |
|
302 | + do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification); |
|
303 | 303 | |
304 | 304 | $order_id = $order->get_id(); |
305 | - $this->send_failed_order_email( $order_id ); |
|
305 | + $this->send_failed_order_email($order_id); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -311,34 +311,34 @@ discard block |
||
311 | 311 | * @since 4.4.1 |
312 | 312 | * @param object $notification |
313 | 313 | */ |
314 | - public function process_webhook_dispute_closed( $notification ) { |
|
315 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge ); |
|
314 | + public function process_webhook_dispute_closed($notification) { |
|
315 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge); |
|
316 | 316 | $status = $notification->data->object->status; |
317 | 317 | |
318 | - if ( ! $order ) { |
|
319 | - WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->charge ); |
|
318 | + if ( ! $order) { |
|
319 | + WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->charge); |
|
320 | 320 | return; |
321 | 321 | } |
322 | 322 | |
323 | - if ( 'lost' === $status ) { |
|
324 | - $message = __( 'The dispute was lost or accepted.', 'woocommerce-gateway-stripe' ); |
|
325 | - } elseif ( 'won' === $status ) { |
|
326 | - $message = __( 'The dispute was resolved in your favor.', 'woocommerce-gateway-stripe' ); |
|
327 | - } elseif ( 'warning_closed' === $status ) { |
|
328 | - $message = __( 'The inquiry or retrieval was closed.', 'woocommerce-gateway-stripe' ); |
|
323 | + if ('lost' === $status) { |
|
324 | + $message = __('The dispute was lost or accepted.', 'woocommerce-gateway-stripe'); |
|
325 | + } elseif ('won' === $status) { |
|
326 | + $message = __('The dispute was resolved in your favor.', 'woocommerce-gateway-stripe'); |
|
327 | + } elseif ('warning_closed' === $status) { |
|
328 | + $message = __('The inquiry or retrieval was closed.', 'woocommerce-gateway-stripe'); |
|
329 | 329 | } else { |
330 | 330 | return; |
331 | 331 | } |
332 | 332 | |
333 | - if ( apply_filters( 'wc_stripe_webhook_dispute_change_order_status', true, $order, $notification ) ) { |
|
333 | + if (apply_filters('wc_stripe_webhook_dispute_change_order_status', true, $order, $notification)) { |
|
334 | 334 | // Mark final so that order status is not overridden by out-of-sequence events. |
335 | - $order->update_meta_data( '_stripe_status_final', true ); |
|
335 | + $order->update_meta_data('_stripe_status_final', true); |
|
336 | 336 | |
337 | 337 | // Fail order if dispute is lost, or else revert to pre-dispute status. |
338 | - $order_status = 'lost' === $status ? 'failed' : $order->get_meta( '_stripe_status_before_hold', 'processing' ); |
|
339 | - $order->update_status( $order_status, $message ); |
|
338 | + $order_status = 'lost' === $status ? 'failed' : $order->get_meta('_stripe_status_before_hold', 'processing'); |
|
339 | + $order->update_status($order_status, $message); |
|
340 | 340 | } else { |
341 | - $order->add_order_note( $message ); |
|
341 | + $order->add_order_note($message); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
@@ -350,43 +350,43 @@ discard block |
||
350 | 350 | * @version 4.0.0 |
351 | 351 | * @param object $notification |
352 | 352 | */ |
353 | - public function process_webhook_capture( $notification ) { |
|
354 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id ); |
|
353 | + public function process_webhook_capture($notification) { |
|
354 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id); |
|
355 | 355 | |
356 | - if ( ! $order ) { |
|
357 | - WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id ); |
|
356 | + if ( ! $order) { |
|
357 | + WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id); |
|
358 | 358 | return; |
359 | 359 | } |
360 | 360 | |
361 | - if ( 'stripe' === $order->get_payment_method() ) { |
|
361 | + if ('stripe' === $order->get_payment_method()) { |
|
362 | 362 | $charge = $order->get_transaction_id(); |
363 | - $captured = $order->get_meta( '_stripe_charge_captured', true ); |
|
363 | + $captured = $order->get_meta('_stripe_charge_captured', true); |
|
364 | 364 | |
365 | - if ( $charge && 'no' === $captured ) { |
|
366 | - $order->update_meta_data( '_stripe_charge_captured', 'yes' ); |
|
365 | + if ($charge && 'no' === $captured) { |
|
366 | + $order->update_meta_data('_stripe_charge_captured', 'yes'); |
|
367 | 367 | |
368 | 368 | // Store other data such as fees |
369 | - $order->set_transaction_id( $notification->data->object->id ); |
|
369 | + $order->set_transaction_id($notification->data->object->id); |
|
370 | 370 | |
371 | - if ( isset( $notification->data->object->balance_transaction ) ) { |
|
372 | - $this->update_fees( $order, $notification->data->object->balance_transaction ); |
|
371 | + if (isset($notification->data->object->balance_transaction)) { |
|
372 | + $this->update_fees($order, $notification->data->object->balance_transaction); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // Check and see if capture is partial. |
376 | - if ( $this->is_partial_capture( $notification ) ) { |
|
377 | - $partial_amount = $this->get_partial_amount_to_charge( $notification ); |
|
378 | - $order->set_total( $partial_amount ); |
|
379 | - $this->update_fees( $order, $notification->data->object->refunds->data[0]->balance_transaction ); |
|
376 | + if ($this->is_partial_capture($notification)) { |
|
377 | + $partial_amount = $this->get_partial_amount_to_charge($notification); |
|
378 | + $order->set_total($partial_amount); |
|
379 | + $this->update_fees($order, $notification->data->object->refunds->data[0]->balance_transaction); |
|
380 | 380 | /* translators: partial captured amount */ |
381 | - $order->add_order_note( sprintf( __( 'This charge was partially captured via Stripe Dashboard in the amount of: %s', 'woocommerce-gateway-stripe' ), $partial_amount ) ); |
|
381 | + $order->add_order_note(sprintf(__('This charge was partially captured via Stripe Dashboard in the amount of: %s', 'woocommerce-gateway-stripe'), $partial_amount)); |
|
382 | 382 | } else { |
383 | - $order->payment_complete( $notification->data->object->id ); |
|
383 | + $order->payment_complete($notification->data->object->id); |
|
384 | 384 | |
385 | 385 | /* translators: transaction id */ |
386 | - $order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $notification->data->object->id ) ); |
|
386 | + $order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $notification->data->object->id)); |
|
387 | 387 | } |
388 | 388 | |
389 | - if ( is_callable( array( $order, 'save' ) ) ) { |
|
389 | + if (is_callable(array($order, 'save'))) { |
|
390 | 390 | $order->save(); |
391 | 391 | } |
392 | 392 | } |
@@ -401,41 +401,41 @@ discard block |
||
401 | 401 | * @version 4.0.0 |
402 | 402 | * @param object $notification |
403 | 403 | */ |
404 | - public function process_webhook_charge_succeeded( $notification ) { |
|
404 | + public function process_webhook_charge_succeeded($notification) { |
|
405 | 405 | // Ignore the notification for charges, created through PaymentIntents. |
406 | - if ( isset( $notification->data->object->payment_intent ) && $notification->data->object->payment_intent ) { |
|
406 | + if (isset($notification->data->object->payment_intent) && $notification->data->object->payment_intent) { |
|
407 | 407 | return; |
408 | 408 | } |
409 | 409 | |
410 | 410 | // The following payment methods are synchronous so does not need to be handle via webhook. |
411 | - if ( ( isset( $notification->data->object->source->type ) && 'card' === $notification->data->object->source->type ) || ( isset( $notification->data->object->source->type ) && 'three_d_secure' === $notification->data->object->source->type ) ) { |
|
411 | + if ((isset($notification->data->object->source->type) && 'card' === $notification->data->object->source->type) || (isset($notification->data->object->source->type) && 'three_d_secure' === $notification->data->object->source->type)) { |
|
412 | 412 | return; |
413 | 413 | } |
414 | 414 | |
415 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id ); |
|
415 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id); |
|
416 | 416 | |
417 | - if ( ! $order ) { |
|
418 | - WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id ); |
|
417 | + if ( ! $order) { |
|
418 | + WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id); |
|
419 | 419 | return; |
420 | 420 | } |
421 | 421 | |
422 | - if ( ! $order->has_status( 'on-hold' ) ) { |
|
422 | + if ( ! $order->has_status('on-hold')) { |
|
423 | 423 | return; |
424 | 424 | } |
425 | 425 | |
426 | 426 | // Store other data such as fees |
427 | - $order->set_transaction_id( $notification->data->object->id ); |
|
427 | + $order->set_transaction_id($notification->data->object->id); |
|
428 | 428 | |
429 | - if ( isset( $notification->data->object->balance_transaction ) ) { |
|
430 | - $this->update_fees( $order, $notification->data->object->balance_transaction ); |
|
429 | + if (isset($notification->data->object->balance_transaction)) { |
|
430 | + $this->update_fees($order, $notification->data->object->balance_transaction); |
|
431 | 431 | } |
432 | 432 | |
433 | - $order->payment_complete( $notification->data->object->id ); |
|
433 | + $order->payment_complete($notification->data->object->id); |
|
434 | 434 | |
435 | 435 | /* translators: transaction id */ |
436 | - $order->add_order_note( sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $notification->data->object->id ) ); |
|
436 | + $order->add_order_note(sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $notification->data->object->id)); |
|
437 | 437 | |
438 | - if ( is_callable( array( $order, 'save' ) ) ) { |
|
438 | + if (is_callable(array($order, 'save'))) { |
|
439 | 439 | $order->save(); |
440 | 440 | } |
441 | 441 | } |
@@ -447,27 +447,27 @@ discard block |
||
447 | 447 | * @since 4.1.5 Can handle any fail payments from any methods. |
448 | 448 | * @param object $notification |
449 | 449 | */ |
450 | - public function process_webhook_charge_failed( $notification ) { |
|
451 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id ); |
|
450 | + public function process_webhook_charge_failed($notification) { |
|
451 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id); |
|
452 | 452 | |
453 | - if ( ! $order ) { |
|
454 | - WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id ); |
|
453 | + if ( ! $order) { |
|
454 | + WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id); |
|
455 | 455 | return; |
456 | 456 | } |
457 | 457 | |
458 | 458 | // If order status is already in failed status don't continue. |
459 | - if ( $order->has_status( 'failed' ) ) { |
|
459 | + if ($order->has_status('failed')) { |
|
460 | 460 | return; |
461 | 461 | } |
462 | 462 | |
463 | - $message = __( 'This payment failed to clear.', 'woocommerce-gateway-stripe' ); |
|
464 | - if ( ! $order->get_meta( '_stripe_status_final', false ) ) { |
|
465 | - $order->update_status( 'failed', $message ); |
|
463 | + $message = __('This payment failed to clear.', 'woocommerce-gateway-stripe'); |
|
464 | + if ( ! $order->get_meta('_stripe_status_final', false)) { |
|
465 | + $order->update_status('failed', $message); |
|
466 | 466 | } else { |
467 | - $order->add_order_note( $message ); |
|
467 | + $order->add_order_note($message); |
|
468 | 468 | } |
469 | 469 | |
470 | - do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification ); |
|
470 | + do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | /** |
@@ -478,33 +478,33 @@ discard block |
||
478 | 478 | * @since 4.1.15 Add check to make sure order is processed by Stripe. |
479 | 479 | * @param object $notification |
480 | 480 | */ |
481 | - public function process_webhook_source_canceled( $notification ) { |
|
482 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id ); |
|
481 | + public function process_webhook_source_canceled($notification) { |
|
482 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id); |
|
483 | 483 | |
484 | 484 | // If can't find order by charge ID, try source ID. |
485 | - if ( ! $order ) { |
|
486 | - $order = WC_Stripe_Helper::get_order_by_source_id( $notification->data->object->id ); |
|
485 | + if ( ! $order) { |
|
486 | + $order = WC_Stripe_Helper::get_order_by_source_id($notification->data->object->id); |
|
487 | 487 | |
488 | - if ( ! $order ) { |
|
489 | - WC_Stripe_Logger::log( 'Could not find order via charge/source ID: ' . $notification->data->object->id ); |
|
488 | + if ( ! $order) { |
|
489 | + WC_Stripe_Logger::log('Could not find order via charge/source ID: ' . $notification->data->object->id); |
|
490 | 490 | return; |
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
494 | 494 | // Don't proceed if payment method isn't Stripe. |
495 | - if ( 'stripe' !== $order->get_payment_method() ) { |
|
496 | - WC_Stripe_Logger::log( 'Canceled webhook abort: Order was not processed by Stripe: ' . $order->get_id() ); |
|
495 | + if ('stripe' !== $order->get_payment_method()) { |
|
496 | + WC_Stripe_Logger::log('Canceled webhook abort: Order was not processed by Stripe: ' . $order->get_id()); |
|
497 | 497 | return; |
498 | 498 | } |
499 | 499 | |
500 | - $message = __( 'This payment was cancelled.', 'woocommerce-gateway-stripe' ); |
|
501 | - if ( ! $order->has_status( 'cancelled' ) && ! $order->get_meta( '_stripe_status_final', false ) ) { |
|
502 | - $order->update_status( 'cancelled', $message ); |
|
500 | + $message = __('This payment was cancelled.', 'woocommerce-gateway-stripe'); |
|
501 | + if ( ! $order->has_status('cancelled') && ! $order->get_meta('_stripe_status_final', false)) { |
|
502 | + $order->update_status('cancelled', $message); |
|
503 | 503 | } else { |
504 | - $order->add_order_note( $message ); |
|
504 | + $order->add_order_note($message); |
|
505 | 505 | } |
506 | 506 | |
507 | - do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification ); |
|
507 | + do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -514,59 +514,59 @@ discard block |
||
514 | 514 | * @version 4.0.0 |
515 | 515 | * @param object $notification |
516 | 516 | */ |
517 | - public function process_webhook_refund( $notification ) { |
|
518 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->id ); |
|
517 | + public function process_webhook_refund($notification) { |
|
518 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->id); |
|
519 | 519 | |
520 | - if ( ! $order ) { |
|
521 | - WC_Stripe_Logger::log( 'Could not find order via charge ID: ' . $notification->data->object->id ); |
|
520 | + if ( ! $order) { |
|
521 | + WC_Stripe_Logger::log('Could not find order via charge ID: ' . $notification->data->object->id); |
|
522 | 522 | return; |
523 | 523 | } |
524 | 524 | |
525 | 525 | $order_id = $order->get_id(); |
526 | 526 | |
527 | - if ( 'stripe' === $order->get_payment_method() ) { |
|
527 | + if ('stripe' === $order->get_payment_method()) { |
|
528 | 528 | $charge = $order->get_transaction_id(); |
529 | - $captured = $order->get_meta( '_stripe_charge_captured', true ); |
|
530 | - $refund_id = $order->get_meta( '_stripe_refund_id', true ); |
|
529 | + $captured = $order->get_meta('_stripe_charge_captured', true); |
|
530 | + $refund_id = $order->get_meta('_stripe_refund_id', true); |
|
531 | 531 | |
532 | 532 | // If the refund ID matches, don't continue to prevent double refunding. |
533 | - if ( $notification->data->object->refunds->data[0]->id === $refund_id ) { |
|
533 | + if ($notification->data->object->refunds->data[0]->id === $refund_id) { |
|
534 | 534 | return; |
535 | 535 | } |
536 | 536 | |
537 | 537 | // Only refund captured charge. |
538 | - if ( $charge ) { |
|
539 | - $reason = ( isset( $captured ) && 'yes' === $captured ) ? __( 'Refunded via Stripe Dashboard', 'woocommerce-gateway-stripe' ) : __( 'Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe' ); |
|
538 | + if ($charge) { |
|
539 | + $reason = (isset($captured) && 'yes' === $captured) ? __('Refunded via Stripe Dashboard', 'woocommerce-gateway-stripe') : __('Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe'); |
|
540 | 540 | |
541 | 541 | // Create the refund. |
542 | 542 | $refund = wc_create_refund( |
543 | 543 | array( |
544 | 544 | 'order_id' => $order_id, |
545 | - 'amount' => $this->get_refund_amount( $notification ), |
|
545 | + 'amount' => $this->get_refund_amount($notification), |
|
546 | 546 | 'reason' => $reason, |
547 | 547 | ) |
548 | 548 | ); |
549 | 549 | |
550 | - if ( is_wp_error( $refund ) ) { |
|
551 | - WC_Stripe_Logger::log( $refund->get_error_message() ); |
|
550 | + if (is_wp_error($refund)) { |
|
551 | + WC_Stripe_Logger::log($refund->get_error_message()); |
|
552 | 552 | } |
553 | 553 | |
554 | - $order->update_meta_data( '_stripe_refund_id', $notification->data->object->refunds->data[0]->id ); |
|
554 | + $order->update_meta_data('_stripe_refund_id', $notification->data->object->refunds->data[0]->id); |
|
555 | 555 | |
556 | - $amount = wc_price( $notification->data->object->refunds->data[0]->amount / 100 ); |
|
556 | + $amount = wc_price($notification->data->object->refunds->data[0]->amount / 100); |
|
557 | 557 | |
558 | - if ( in_array( strtolower( $order->get_currency() ), WC_Stripe_Helper::no_decimal_currencies() ) ) { |
|
559 | - $amount = wc_price( $notification->data->object->refunds->data[0]->amount ); |
|
558 | + if (in_array(strtolower($order->get_currency()), WC_Stripe_Helper::no_decimal_currencies())) { |
|
559 | + $amount = wc_price($notification->data->object->refunds->data[0]->amount); |
|
560 | 560 | } |
561 | 561 | |
562 | - if ( isset( $notification->data->object->refunds->data[0]->balance_transaction ) ) { |
|
563 | - $this->update_fees( $order, $notification->data->object->refunds->data[0]->balance_transaction ); |
|
562 | + if (isset($notification->data->object->refunds->data[0]->balance_transaction)) { |
|
563 | + $this->update_fees($order, $notification->data->object->refunds->data[0]->balance_transaction); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /* translators: 1) dollar amount 2) transaction id 3) refund message */ |
567 | - $refund_message = ( isset( $captured ) && 'yes' === $captured ) ? sprintf( __( 'Refunded %1$s - Refund ID: %2$s - %3$s', 'woocommerce-gateway-stripe' ), $amount, $notification->data->object->refunds->data[0]->id, $reason ) : __( 'Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe' ); |
|
567 | + $refund_message = (isset($captured) && 'yes' === $captured) ? sprintf(__('Refunded %1$s - Refund ID: %2$s - %3$s', 'woocommerce-gateway-stripe'), $amount, $notification->data->object->refunds->data[0]->id, $reason) : __('Pre-Authorization Released via Stripe Dashboard', 'woocommerce-gateway-stripe'); |
|
568 | 568 | |
569 | - $order->add_order_note( $refund_message ); |
|
569 | + $order->add_order_note($refund_message); |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | } |
@@ -577,32 +577,32 @@ discard block |
||
577 | 577 | * @since 4.0.6 |
578 | 578 | * @param object $notification |
579 | 579 | */ |
580 | - public function process_review_opened( $notification ) { |
|
581 | - if ( isset( $notification->data->object->payment_intent ) ) { |
|
582 | - $order = WC_Stripe_Helper::get_order_by_intent_id( $notification->data->object->payment_intent ); |
|
580 | + public function process_review_opened($notification) { |
|
581 | + if (isset($notification->data->object->payment_intent)) { |
|
582 | + $order = WC_Stripe_Helper::get_order_by_intent_id($notification->data->object->payment_intent); |
|
583 | 583 | |
584 | - if ( ! $order ) { |
|
585 | - WC_Stripe_Logger::log( '[Review Opened] Could not find order via intent ID: ' . $notification->data->object->payment_intent ); |
|
584 | + if ( ! $order) { |
|
585 | + WC_Stripe_Logger::log('[Review Opened] Could not find order via intent ID: ' . $notification->data->object->payment_intent); |
|
586 | 586 | return; |
587 | 587 | } |
588 | 588 | } else { |
589 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge ); |
|
589 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge); |
|
590 | 590 | |
591 | - if ( ! $order ) { |
|
592 | - WC_Stripe_Logger::log( '[Review Opened] Could not find order via charge ID: ' . $notification->data->object->charge ); |
|
591 | + if ( ! $order) { |
|
592 | + WC_Stripe_Logger::log('[Review Opened] Could not find order via charge ID: ' . $notification->data->object->charge); |
|
593 | 593 | return; |
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | - $order->update_meta_data( '_stripe_status_before_hold', $order->get_status() ); |
|
597 | + $order->update_meta_data('_stripe_status_before_hold', $order->get_status()); |
|
598 | 598 | |
599 | 599 | /* translators: 1) The URL to the order. 2) The reason type. */ |
600 | - $message = sprintf( __( 'A review has been opened for this order. Action is needed. Please go to your <a href="%1$s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review the issue. Reason: (%2$s)', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ), $notification->data->object->reason ); |
|
600 | + $message = sprintf(__('A review has been opened for this order. Action is needed. Please go to your <a href="%1$s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review the issue. Reason: (%2$s)', 'woocommerce-gateway-stripe'), $this->get_transaction_url($order), $notification->data->object->reason); |
|
601 | 601 | |
602 | - if ( apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) && ! $order->get_meta( '_stripe_status_final', false ) ) { |
|
603 | - $order->update_status( 'on-hold', $message ); |
|
602 | + if (apply_filters('wc_stripe_webhook_review_change_order_status', true, $order, $notification) && ! $order->get_meta('_stripe_status_final', false)) { |
|
603 | + $order->update_status('on-hold', $message); |
|
604 | 604 | } else { |
605 | - $order->add_order_note( $message ); |
|
605 | + $order->add_order_note($message); |
|
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
@@ -612,34 +612,34 @@ discard block |
||
612 | 612 | * @since 4.0.6 |
613 | 613 | * @param object $notification |
614 | 614 | */ |
615 | - public function process_review_closed( $notification ) { |
|
616 | - if ( isset( $notification->data->object->payment_intent ) ) { |
|
617 | - $order = WC_Stripe_Helper::get_order_by_intent_id( $notification->data->object->payment_intent ); |
|
615 | + public function process_review_closed($notification) { |
|
616 | + if (isset($notification->data->object->payment_intent)) { |
|
617 | + $order = WC_Stripe_Helper::get_order_by_intent_id($notification->data->object->payment_intent); |
|
618 | 618 | |
619 | - if ( ! $order ) { |
|
620 | - WC_Stripe_Logger::log( '[Review Closed] Could not find order via intent ID: ' . $notification->data->object->payment_intent ); |
|
619 | + if ( ! $order) { |
|
620 | + WC_Stripe_Logger::log('[Review Closed] Could not find order via intent ID: ' . $notification->data->object->payment_intent); |
|
621 | 621 | return; |
622 | 622 | } |
623 | 623 | } else { |
624 | - $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge ); |
|
624 | + $order = WC_Stripe_Helper::get_order_by_charge_id($notification->data->object->charge); |
|
625 | 625 | |
626 | - if ( ! $order ) { |
|
627 | - WC_Stripe_Logger::log( '[Review Closed] Could not find order via charge ID: ' . $notification->data->object->charge ); |
|
626 | + if ( ! $order) { |
|
627 | + WC_Stripe_Logger::log('[Review Closed] Could not find order via charge ID: ' . $notification->data->object->charge); |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | } |
631 | 631 | |
632 | 632 | /* translators: 1) The reason type. */ |
633 | - $message = sprintf( __( 'The opened review for this order is now closed. Reason: (%s)', 'woocommerce-gateway-stripe' ), $notification->data->object->reason ); |
|
633 | + $message = sprintf(__('The opened review for this order is now closed. Reason: (%s)', 'woocommerce-gateway-stripe'), $notification->data->object->reason); |
|
634 | 634 | |
635 | 635 | if ( |
636 | - $order->has_status( 'on-hold' ) && |
|
637 | - apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) && |
|
638 | - ! $order->get_meta( '_stripe_status_final', false ) |
|
636 | + $order->has_status('on-hold') && |
|
637 | + apply_filters('wc_stripe_webhook_review_change_order_status', true, $order, $notification) && |
|
638 | + ! $order->get_meta('_stripe_status_final', false) |
|
639 | 639 | ) { |
640 | - $order->update_status( $order->get_meta( '_stripe_status_before_hold', 'processing' ), $message ); |
|
640 | + $order->update_status($order->get_meta('_stripe_status_before_hold', 'processing'), $message); |
|
641 | 641 | } else { |
642 | - $order->add_order_note( $message ); |
|
642 | + $order->add_order_note($message); |
|
643 | 643 | } |
644 | 644 | } |
645 | 645 | |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | * @version 4.0.0 |
651 | 651 | * @param object $notification |
652 | 652 | */ |
653 | - public function is_partial_capture( $notification ) { |
|
653 | + public function is_partial_capture($notification) { |
|
654 | 654 | return 0 < $notification->data->object->amount_refunded; |
655 | 655 | } |
656 | 656 | |
@@ -661,11 +661,11 @@ discard block |
||
661 | 661 | * @version 4.0.0 |
662 | 662 | * @param object $notification |
663 | 663 | */ |
664 | - public function get_refund_amount( $notification ) { |
|
665 | - if ( $this->is_partial_capture( $notification ) ) { |
|
664 | + public function get_refund_amount($notification) { |
|
665 | + if ($this->is_partial_capture($notification)) { |
|
666 | 666 | $amount = $notification->data->object->refunds->data[0]->amount / 100; |
667 | 667 | |
668 | - if ( in_array( strtolower( $notification->data->object->currency ), WC_Stripe_Helper::no_decimal_currencies() ) ) { |
|
668 | + if (in_array(strtolower($notification->data->object->currency), WC_Stripe_Helper::no_decimal_currencies())) { |
|
669 | 669 | $amount = $notification->data->object->refunds->data[0]->amount; |
670 | 670 | } |
671 | 671 | |
@@ -682,12 +682,12 @@ discard block |
||
682 | 682 | * @version 4.0.0 |
683 | 683 | * @param object $notification |
684 | 684 | */ |
685 | - public function get_partial_amount_to_charge( $notification ) { |
|
686 | - if ( $this->is_partial_capture( $notification ) ) { |
|
687 | - $amount = ( $notification->data->object->amount - $notification->data->object->amount_refunded ) / 100; |
|
685 | + public function get_partial_amount_to_charge($notification) { |
|
686 | + if ($this->is_partial_capture($notification)) { |
|
687 | + $amount = ($notification->data->object->amount - $notification->data->object->amount_refunded) / 100; |
|
688 | 688 | |
689 | - if ( in_array( strtolower( $notification->data->object->currency ), WC_Stripe_Helper::no_decimal_currencies() ) ) { |
|
690 | - $amount = ( $notification->data->object->amount - $notification->data->object->amount_refunded ); |
|
689 | + if (in_array(strtolower($notification->data->object->currency), WC_Stripe_Helper::no_decimal_currencies())) { |
|
690 | + $amount = ($notification->data->object->amount - $notification->data->object->amount_refunded); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | return $amount; |
@@ -696,75 +696,75 @@ discard block |
||
696 | 696 | return false; |
697 | 697 | } |
698 | 698 | |
699 | - public function process_payment_intent_success( $notification ) { |
|
699 | + public function process_payment_intent_success($notification) { |
|
700 | 700 | $intent = $notification->data->object; |
701 | - $order = WC_Stripe_Helper::get_order_by_intent_id( $intent->id ); |
|
701 | + $order = WC_Stripe_Helper::get_order_by_intent_id($intent->id); |
|
702 | 702 | |
703 | - if ( ! $order ) { |
|
704 | - WC_Stripe_Logger::log( 'Could not find order via intent ID: ' . $intent->id ); |
|
703 | + if ( ! $order) { |
|
704 | + WC_Stripe_Logger::log('Could not find order via intent ID: ' . $intent->id); |
|
705 | 705 | return; |
706 | 706 | } |
707 | 707 | |
708 | - if ( ! $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
708 | + if ( ! $order->has_status(array('pending', 'failed'))) { |
|
709 | 709 | return; |
710 | 710 | } |
711 | 711 | |
712 | - if ( $this->lock_order_payment( $order, $intent ) ) { |
|
712 | + if ($this->lock_order_payment($order, $intent)) { |
|
713 | 713 | return; |
714 | 714 | } |
715 | 715 | |
716 | 716 | $order_id = $order->get_id(); |
717 | - if ( 'payment_intent.succeeded' === $notification->type || 'payment_intent.amount_capturable_updated' === $notification->type ) { |
|
718 | - $charge = end( $intent->charges->data ); |
|
719 | - WC_Stripe_Logger::log( "Stripe PaymentIntent $intent->id succeeded for order $order_id" ); |
|
717 | + if ('payment_intent.succeeded' === $notification->type || 'payment_intent.amount_capturable_updated' === $notification->type) { |
|
718 | + $charge = end($intent->charges->data); |
|
719 | + WC_Stripe_Logger::log("Stripe PaymentIntent $intent->id succeeded for order $order_id"); |
|
720 | 720 | |
721 | - do_action( 'wc_gateway_stripe_process_payment', $charge, $order ); |
|
721 | + do_action('wc_gateway_stripe_process_payment', $charge, $order); |
|
722 | 722 | |
723 | 723 | // Process valid response. |
724 | - $this->process_response( $charge, $order ); |
|
724 | + $this->process_response($charge, $order); |
|
725 | 725 | |
726 | 726 | } else { |
727 | 727 | $error_message = $intent->last_payment_error ? $intent->last_payment_error->message : ""; |
728 | 728 | |
729 | 729 | /* translators: 1) The error message that was received from Stripe. */ |
730 | - $message = sprintf( __( 'Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe' ), $error_message ); |
|
730 | + $message = sprintf(__('Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe'), $error_message); |
|
731 | 731 | |
732 | - if ( ! $order->get_meta( '_stripe_status_final', false ) ) { |
|
733 | - $order->update_status( 'failed', $message ); |
|
732 | + if ( ! $order->get_meta('_stripe_status_final', false)) { |
|
733 | + $order->update_status('failed', $message); |
|
734 | 734 | } else { |
735 | - $order->add_order_note( $message ); |
|
735 | + $order->add_order_note($message); |
|
736 | 736 | } |
737 | 737 | |
738 | - do_action( 'wc_gateway_stripe_process_webhook_payment_error', $order, $notification ); |
|
738 | + do_action('wc_gateway_stripe_process_webhook_payment_error', $order, $notification); |
|
739 | 739 | |
740 | - $this->send_failed_order_email( $order_id ); |
|
740 | + $this->send_failed_order_email($order_id); |
|
741 | 741 | } |
742 | 742 | |
743 | - $this->unlock_order_payment( $order ); |
|
743 | + $this->unlock_order_payment($order); |
|
744 | 744 | } |
745 | 745 | |
746 | - public function process_setup_intent( $notification ) { |
|
746 | + public function process_setup_intent($notification) { |
|
747 | 747 | $intent = $notification->data->object; |
748 | - $order = WC_Stripe_Helper::get_order_by_setup_intent_id( $intent->id ); |
|
748 | + $order = WC_Stripe_Helper::get_order_by_setup_intent_id($intent->id); |
|
749 | 749 | |
750 | - if ( ! $order ) { |
|
751 | - WC_Stripe_Logger::log( 'Could not find order via setup intent ID: ' . $intent->id ); |
|
750 | + if ( ! $order) { |
|
751 | + WC_Stripe_Logger::log('Could not find order via setup intent ID: ' . $intent->id); |
|
752 | 752 | return; |
753 | 753 | } |
754 | 754 | |
755 | - if ( ! $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
755 | + if ( ! $order->has_status(array('pending', 'failed'))) { |
|
756 | 756 | return; |
757 | 757 | } |
758 | 758 | |
759 | - if ( $this->lock_order_payment( $order, $intent ) ) { |
|
759 | + if ($this->lock_order_payment($order, $intent)) { |
|
760 | 760 | return; |
761 | 761 | } |
762 | 762 | |
763 | 763 | $order_id = $order->get_id(); |
764 | - if ( 'setup_intent.succeeded' === $notification->type ) { |
|
765 | - WC_Stripe_Logger::log( "Stripe SetupIntent $intent->id succeeded for order $order_id" ); |
|
766 | - if ( WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order( $order ) ) { |
|
767 | - WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order ); |
|
764 | + if ('setup_intent.succeeded' === $notification->type) { |
|
765 | + WC_Stripe_Logger::log("Stripe SetupIntent $intent->id succeeded for order $order_id"); |
|
766 | + if (WC_Stripe_Helper::is_pre_orders_exists() && WC_Pre_Orders_Order::order_contains_pre_order($order)) { |
|
767 | + WC_Pre_Orders_Order::mark_order_as_pre_ordered($order); |
|
768 | 768 | } else { |
769 | 769 | $order->payment_complete(); |
770 | 770 | } |
@@ -772,18 +772,18 @@ discard block |
||
772 | 772 | $error_message = $intent->last_setup_error ? $intent->last_setup_error->message : ""; |
773 | 773 | |
774 | 774 | /* translators: 1) The error message that was received from Stripe. */ |
775 | - $message = sprintf( __( 'Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe' ), $error_message ); |
|
775 | + $message = sprintf(__('Stripe SCA authentication failed. Reason: %s', 'woocommerce-gateway-stripe'), $error_message); |
|
776 | 776 | |
777 | - if ( ! $order->get_meta( '_stripe_status_final', false ) ) { |
|
778 | - $order->update_status( 'failed', $message ); |
|
777 | + if ( ! $order->get_meta('_stripe_status_final', false)) { |
|
778 | + $order->update_status('failed', $message); |
|
779 | 779 | } else { |
780 | - $order->add_order_note( $message ); |
|
780 | + $order->add_order_note($message); |
|
781 | 781 | } |
782 | 782 | |
783 | - $this->send_failed_order_email( $order_id ); |
|
783 | + $this->send_failed_order_email($order_id); |
|
784 | 784 | } |
785 | 785 | |
786 | - $this->unlock_order_payment( $order ); |
|
786 | + $this->unlock_order_payment($order); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -793,59 +793,59 @@ discard block |
||
793 | 793 | * @version 4.0.0 |
794 | 794 | * @param string $request_body |
795 | 795 | */ |
796 | - public function process_webhook( $request_body ) { |
|
797 | - $notification = json_decode( $request_body ); |
|
796 | + public function process_webhook($request_body) { |
|
797 | + $notification = json_decode($request_body); |
|
798 | 798 | |
799 | - switch ( $notification->type ) { |
|
799 | + switch ($notification->type) { |
|
800 | 800 | case 'source.chargeable': |
801 | - $this->process_webhook_payment( $notification ); |
|
801 | + $this->process_webhook_payment($notification); |
|
802 | 802 | break; |
803 | 803 | |
804 | 804 | case 'source.canceled': |
805 | - $this->process_webhook_source_canceled( $notification ); |
|
805 | + $this->process_webhook_source_canceled($notification); |
|
806 | 806 | break; |
807 | 807 | |
808 | 808 | case 'charge.succeeded': |
809 | - $this->process_webhook_charge_succeeded( $notification ); |
|
809 | + $this->process_webhook_charge_succeeded($notification); |
|
810 | 810 | break; |
811 | 811 | |
812 | 812 | case 'charge.failed': |
813 | - $this->process_webhook_charge_failed( $notification ); |
|
813 | + $this->process_webhook_charge_failed($notification); |
|
814 | 814 | break; |
815 | 815 | |
816 | 816 | case 'charge.captured': |
817 | - $this->process_webhook_capture( $notification ); |
|
817 | + $this->process_webhook_capture($notification); |
|
818 | 818 | break; |
819 | 819 | |
820 | 820 | case 'charge.dispute.created': |
821 | - $this->process_webhook_dispute( $notification ); |
|
821 | + $this->process_webhook_dispute($notification); |
|
822 | 822 | break; |
823 | 823 | |
824 | 824 | case 'charge.dispute.closed': |
825 | - $this->process_webhook_dispute_closed( $notification ); |
|
825 | + $this->process_webhook_dispute_closed($notification); |
|
826 | 826 | break; |
827 | 827 | |
828 | 828 | case 'charge.refunded': |
829 | - $this->process_webhook_refund( $notification ); |
|
829 | + $this->process_webhook_refund($notification); |
|
830 | 830 | break; |
831 | 831 | |
832 | 832 | case 'review.opened': |
833 | - $this->process_review_opened( $notification ); |
|
833 | + $this->process_review_opened($notification); |
|
834 | 834 | break; |
835 | 835 | |
836 | 836 | case 'review.closed': |
837 | - $this->process_review_closed( $notification ); |
|
837 | + $this->process_review_closed($notification); |
|
838 | 838 | break; |
839 | 839 | |
840 | 840 | case 'payment_intent.succeeded': |
841 | 841 | case 'payment_intent.payment_failed': |
842 | 842 | case 'payment_intent.amount_capturable_updated': |
843 | - $this->process_payment_intent_success( $notification ); |
|
843 | + $this->process_payment_intent_success($notification); |
|
844 | 844 | break; |
845 | 845 | |
846 | 846 | case 'setup_intent.succeeded': |
847 | 847 | case 'setup_intent.setup_failed': |
848 | - $this->process_setup_intent( $notification ); |
|
848 | + $this->process_setup_intent($notification); |
|
849 | 849 | |
850 | 850 | } |
851 | 851 | } |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | -if ( woocommerce_gateway_stripe()->connect->is_connected() ) { |
|
6 | +if (woocommerce_gateway_stripe()->connect->is_connected()) { |
|
7 | 7 | $reset_link = add_query_arg( |
8 | 8 | array( |
9 | - '_wpnonce' => wp_create_nonce( 'reset_stripe_api_credentials' ), |
|
9 | + '_wpnonce' => wp_create_nonce('reset_stripe_api_credentials'), |
|
10 | 10 | 'reset_stripe_api_credentials' => true, |
11 | 11 | ), |
12 | - admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) |
|
12 | + admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe') |
|
13 | 13 | ); |
14 | 14 | |
15 | 15 | $api_credentials_text = sprintf( |
16 | - __( '%1$sClear all Stripe account keys.%2$s %3$sThis will disable any connection to Stripe.%4$s', 'woocommerce-gateway-stripe' ), |
|
16 | + __('%1$sClear all Stripe account keys.%2$s %3$sThis will disable any connection to Stripe.%4$s', 'woocommerce-gateway-stripe'), |
|
17 | 17 | '<a id="wc_stripe_connect_button" href="' . $reset_link . '" class="button button-secondary">', |
18 | 18 | '</a>', |
19 | 19 | '<span style="color:red;">', |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | } else { |
23 | 23 | $oauth_url = woocommerce_gateway_stripe()->connect->get_oauth_url(); |
24 | 24 | |
25 | - if ( ! is_wp_error( $oauth_url ) ) { |
|
25 | + if ( ! is_wp_error($oauth_url)) { |
|
26 | 26 | $api_credentials_text = sprintf( |
27 | - __( '%1$sSetup or link an existing Stripe account.%2$s By clicking this button you agree to the %3$sTerms of Service%2$s. Or, manually enter Stripe account keys below.', 'woocommerce-gateway-stripe' ), |
|
27 | + __('%1$sSetup or link an existing Stripe account.%2$s By clicking this button you agree to the %3$sTerms of Service%2$s. Or, manually enter Stripe account keys below.', 'woocommerce-gateway-stripe'), |
|
28 | 28 | '<a id="wc_stripe_connect_button" href="' . $oauth_url . '" class="button button-primary">', |
29 | 29 | '</a>', |
30 | 30 | '<a href="https://wordpress.com/tos">' |
31 | 31 | |
32 | 32 | ); |
33 | 33 | } else { |
34 | - $api_credentials_text = __( 'Manually enter Stripe keys below.', 'woocommerce-gateway-stripe' ); |
|
34 | + $api_credentials_text = __('Manually enter Stripe keys below.', 'woocommerce-gateway-stripe'); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
@@ -39,114 +39,114 @@ discard block |
||
39 | 39 | 'wc_stripe_settings', |
40 | 40 | array( |
41 | 41 | 'enabled' => array( |
42 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
43 | - 'label' => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ), |
|
42 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
43 | + 'label' => __('Enable Stripe', 'woocommerce-gateway-stripe'), |
|
44 | 44 | 'type' => 'checkbox', |
45 | 45 | 'description' => '', |
46 | 46 | 'default' => 'no', |
47 | 47 | ), |
48 | 48 | 'title' => array( |
49 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
49 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
50 | 50 | 'type' => 'text', |
51 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
52 | - 'default' => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ), |
|
51 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
52 | + 'default' => __('Credit Card (Stripe)', 'woocommerce-gateway-stripe'), |
|
53 | 53 | 'desc_tip' => true, |
54 | 54 | ), |
55 | 55 | 'description' => array( |
56 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
56 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
57 | 57 | 'type' => 'text', |
58 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
59 | - 'default' => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ), |
|
58 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
59 | + 'default' => __('Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe'), |
|
60 | 60 | 'desc_tip' => true, |
61 | 61 | ), |
62 | 62 | 'webhook' => array( |
63 | - 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), |
|
63 | + 'title' => __('Webhook Endpoints', 'woocommerce-gateway-stripe'), |
|
64 | 64 | 'type' => 'title', |
65 | 65 | /* translators: webhook URL */ |
66 | 66 | 'description' => $this->display_admin_settings_webhook_description(), |
67 | 67 | ), |
68 | 68 | 'api_credentials' => array( |
69 | - 'title' => __( 'Stripe Account Keys', 'woocommerce-gateway-stripe' ), |
|
69 | + 'title' => __('Stripe Account Keys', 'woocommerce-gateway-stripe'), |
|
70 | 70 | 'type' => 'title', |
71 | 71 | 'description' => $api_credentials_text |
72 | 72 | ), |
73 | 73 | 'testmode' => array( |
74 | - 'title' => __( 'Test mode', 'woocommerce-gateway-stripe' ), |
|
75 | - 'label' => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ), |
|
74 | + 'title' => __('Test mode', 'woocommerce-gateway-stripe'), |
|
75 | + 'label' => __('Enable Test Mode', 'woocommerce-gateway-stripe'), |
|
76 | 76 | 'type' => 'checkbox', |
77 | - 'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ), |
|
77 | + 'description' => __('Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe'), |
|
78 | 78 | 'default' => 'yes', |
79 | 79 | 'desc_tip' => true, |
80 | 80 | ), |
81 | 81 | 'test_publishable_key' => array( |
82 | - 'title' => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ), |
|
82 | + 'title' => __('Test Publishable Key', 'woocommerce-gateway-stripe'), |
|
83 | 83 | 'type' => 'text', |
84 | - 'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', 'woocommerce-gateway-stripe' ), |
|
84 | + 'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', 'woocommerce-gateway-stripe'), |
|
85 | 85 | 'default' => '', |
86 | 86 | 'desc_tip' => true, |
87 | 87 | ), |
88 | 88 | 'test_secret_key' => array( |
89 | - 'title' => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ), |
|
89 | + 'title' => __('Test Secret Key', 'woocommerce-gateway-stripe'), |
|
90 | 90 | 'type' => 'password', |
91 | - 'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe' ), |
|
91 | + 'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe'), |
|
92 | 92 | 'default' => '', |
93 | 93 | 'desc_tip' => true, |
94 | 94 | ), |
95 | 95 | 'test_webhook_secret' => array( |
96 | - 'title' => __( 'Test Webhook Secret', 'woocommerce-gateway-stripe' ), |
|
96 | + 'title' => __('Test Webhook Secret', 'woocommerce-gateway-stripe'), |
|
97 | 97 | 'type' => 'password', |
98 | - 'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ), |
|
98 | + 'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'), |
|
99 | 99 | 'default' => '', |
100 | 100 | 'desc_tip' => true, |
101 | 101 | ), |
102 | 102 | 'publishable_key' => array( |
103 | - 'title' => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ), |
|
103 | + 'title' => __('Live Publishable Key', 'woocommerce-gateway-stripe'), |
|
104 | 104 | 'type' => 'text', |
105 | - 'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe' ), |
|
105 | + 'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe'), |
|
106 | 106 | 'default' => '', |
107 | 107 | 'desc_tip' => true, |
108 | 108 | ), |
109 | 109 | 'secret_key' => array( |
110 | - 'title' => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ), |
|
110 | + 'title' => __('Live Secret Key', 'woocommerce-gateway-stripe'), |
|
111 | 111 | 'type' => 'password', |
112 | - 'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe' ), |
|
112 | + 'description' => __('Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe'), |
|
113 | 113 | 'default' => '', |
114 | 114 | 'desc_tip' => true, |
115 | 115 | ), |
116 | 116 | 'webhook_secret' => array( |
117 | - 'title' => __( 'Webhook Secret', 'woocommerce-gateway-stripe' ), |
|
117 | + 'title' => __('Webhook Secret', 'woocommerce-gateway-stripe'), |
|
118 | 118 | 'type' => 'password', |
119 | - 'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ), |
|
119 | + 'description' => __('Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe'), |
|
120 | 120 | 'default' => '', |
121 | 121 | 'desc_tip' => true, |
122 | 122 | ), |
123 | 123 | 'inline_cc_form' => array( |
124 | - 'title' => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ), |
|
124 | + 'title' => __('Inline Credit Card Form', 'woocommerce-gateway-stripe'), |
|
125 | 125 | 'type' => 'checkbox', |
126 | - 'description' => __( 'Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe' ), |
|
126 | + 'description' => __('Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe'), |
|
127 | 127 | 'default' => 'no', |
128 | 128 | 'desc_tip' => true, |
129 | 129 | ), |
130 | 130 | 'statement_descriptor' => array( |
131 | - 'title' => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ), |
|
131 | + 'title' => __('Statement Descriptor', 'woocommerce-gateway-stripe'), |
|
132 | 132 | 'type' => 'text', |
133 | - 'description' => __( 'Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, /, (, ), {, }, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ), |
|
133 | + 'description' => __('Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, /, (, ), {, }, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe'), |
|
134 | 134 | 'default' => '', |
135 | 135 | 'desc_tip' => true, |
136 | 136 | ), |
137 | 137 | 'capture' => array( |
138 | - 'title' => __( 'Capture', 'woocommerce-gateway-stripe' ), |
|
139 | - 'label' => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ), |
|
138 | + 'title' => __('Capture', 'woocommerce-gateway-stripe'), |
|
139 | + 'label' => __('Capture charge immediately', 'woocommerce-gateway-stripe'), |
|
140 | 140 | 'type' => 'checkbox', |
141 | - 'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ), |
|
141 | + 'description' => __('Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe'), |
|
142 | 142 | 'default' => 'yes', |
143 | 143 | 'desc_tip' => true, |
144 | 144 | ), |
145 | 145 | 'payment_request' => array( |
146 | - 'title' => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ), |
|
146 | + 'title' => __('Payment Request Buttons', 'woocommerce-gateway-stripe'), |
|
147 | 147 | 'label' => sprintf( |
148 | 148 | /* translators: 1) br tag 2) Stripe anchor tag 3) Apple anchor tag 4) Stripe dashboard opening anchor tag 5) Stripe dashboard closing anchor tag */ |
149 | - __( 'Enable Payment Request Buttons. (Apple Pay/Google Pay) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service. (Apple Pay domain verification is performed automatically; configuration can be found on the %4$sStripe dashboard%5$s.)', 'woocommerce-gateway-stripe' ), |
|
149 | + __('Enable Payment Request Buttons. (Apple Pay/Google Pay) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service. (Apple Pay domain verification is performed automatically; configuration can be found on the %4$sStripe dashboard%5$s.)', 'woocommerce-gateway-stripe'), |
|
150 | 150 | '<br />', |
151 | 151 | '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>', |
152 | 152 | '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>', |
@@ -154,79 +154,79 @@ discard block |
||
154 | 154 | '</a>' |
155 | 155 | ), |
156 | 156 | 'type' => 'checkbox', |
157 | - 'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ), |
|
157 | + 'description' => __('If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe'), |
|
158 | 158 | 'default' => 'yes', |
159 | 159 | 'desc_tip' => true, |
160 | 160 | ), |
161 | 161 | 'payment_request_button_type' => array( |
162 | - 'title' => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ), |
|
163 | - 'label' => __( 'Button Type', 'woocommerce-gateway-stripe' ), |
|
162 | + 'title' => __('Payment Request Button Type', 'woocommerce-gateway-stripe'), |
|
163 | + 'label' => __('Button Type', 'woocommerce-gateway-stripe'), |
|
164 | 164 | 'type' => 'select', |
165 | - 'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ), |
|
165 | + 'description' => __('Select the button type you would like to show.', 'woocommerce-gateway-stripe'), |
|
166 | 166 | 'default' => 'buy', |
167 | 167 | 'desc_tip' => true, |
168 | 168 | 'options' => array( |
169 | - 'default' => __( 'Default', 'woocommerce-gateway-stripe' ), |
|
170 | - 'buy' => __( 'Buy', 'woocommerce-gateway-stripe' ), |
|
171 | - 'donate' => __( 'Donate', 'woocommerce-gateway-stripe' ), |
|
172 | - 'branded' => __( 'Branded', 'woocommerce-gateway-stripe' ), |
|
173 | - 'custom' => __( 'Custom', 'woocommerce-gateway-stripe' ), |
|
169 | + 'default' => __('Default', 'woocommerce-gateway-stripe'), |
|
170 | + 'buy' => __('Buy', 'woocommerce-gateway-stripe'), |
|
171 | + 'donate' => __('Donate', 'woocommerce-gateway-stripe'), |
|
172 | + 'branded' => __('Branded', 'woocommerce-gateway-stripe'), |
|
173 | + 'custom' => __('Custom', 'woocommerce-gateway-stripe'), |
|
174 | 174 | ), |
175 | 175 | ), |
176 | 176 | 'payment_request_button_theme' => array( |
177 | - 'title' => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ), |
|
178 | - 'label' => __( 'Button Theme', 'woocommerce-gateway-stripe' ), |
|
177 | + 'title' => __('Payment Request Button Theme', 'woocommerce-gateway-stripe'), |
|
178 | + 'label' => __('Button Theme', 'woocommerce-gateway-stripe'), |
|
179 | 179 | 'type' => 'select', |
180 | - 'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ), |
|
180 | + 'description' => __('Select the button theme you would like to show.', 'woocommerce-gateway-stripe'), |
|
181 | 181 | 'default' => 'dark', |
182 | 182 | 'desc_tip' => true, |
183 | 183 | 'options' => array( |
184 | - 'dark' => __( 'Dark', 'woocommerce-gateway-stripe' ), |
|
185 | - 'light' => __( 'Light', 'woocommerce-gateway-stripe' ), |
|
186 | - 'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ), |
|
184 | + 'dark' => __('Dark', 'woocommerce-gateway-stripe'), |
|
185 | + 'light' => __('Light', 'woocommerce-gateway-stripe'), |
|
186 | + 'light-outline' => __('Light-Outline', 'woocommerce-gateway-stripe'), |
|
187 | 187 | ), |
188 | 188 | ), |
189 | 189 | 'payment_request_button_height' => array( |
190 | - 'title' => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ), |
|
191 | - 'label' => __( 'Button Height', 'woocommerce-gateway-stripe' ), |
|
190 | + 'title' => __('Payment Request Button Height', 'woocommerce-gateway-stripe'), |
|
191 | + 'label' => __('Button Height', 'woocommerce-gateway-stripe'), |
|
192 | 192 | 'type' => 'text', |
193 | - 'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ), |
|
193 | + 'description' => __('Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe'), |
|
194 | 194 | 'default' => '44', |
195 | 195 | 'desc_tip' => true, |
196 | 196 | ), |
197 | 197 | 'payment_request_button_label' => array( |
198 | - 'title' => __( 'Payment Request Button Label', 'woocommerce-gateway-stripe' ), |
|
199 | - 'label' => __( 'Button Label', 'woocommerce-gateway-stripe' ), |
|
198 | + 'title' => __('Payment Request Button Label', 'woocommerce-gateway-stripe'), |
|
199 | + 'label' => __('Button Label', 'woocommerce-gateway-stripe'), |
|
200 | 200 | 'type' => 'text', |
201 | - 'description' => __( 'Enter the custom text you would like the button to have.', 'woocommerce-gateway-stripe' ), |
|
202 | - 'default' => __( 'Buy now', 'woocommerce-gateway-stripe' ), |
|
201 | + 'description' => __('Enter the custom text you would like the button to have.', 'woocommerce-gateway-stripe'), |
|
202 | + 'default' => __('Buy now', 'woocommerce-gateway-stripe'), |
|
203 | 203 | 'desc_tip' => true, |
204 | 204 | ), |
205 | 205 | 'payment_request_button_branded_type' => array( |
206 | - 'title' => __( 'Payment Request Branded Button Label Format', 'woocommerce-gateway-stripe' ), |
|
207 | - 'label' => __( 'Branded Button Label Format', 'woocommerce-gateway-stripe' ), |
|
206 | + 'title' => __('Payment Request Branded Button Label Format', 'woocommerce-gateway-stripe'), |
|
207 | + 'label' => __('Branded Button Label Format', 'woocommerce-gateway-stripe'), |
|
208 | 208 | 'type' => 'select', |
209 | - 'description' => __( 'Select the branded button label format.', 'woocommerce-gateway-stripe' ), |
|
209 | + 'description' => __('Select the branded button label format.', 'woocommerce-gateway-stripe'), |
|
210 | 210 | 'default' => 'long', |
211 | 211 | 'desc_tip' => true, |
212 | 212 | 'options' => array( |
213 | - 'short' => __( 'Logo only', 'woocommerce-gateway-stripe' ), |
|
214 | - 'long' => __( 'Text and logo', 'woocommerce-gateway-stripe' ), |
|
213 | + 'short' => __('Logo only', 'woocommerce-gateway-stripe'), |
|
214 | + 'long' => __('Text and logo', 'woocommerce-gateway-stripe'), |
|
215 | 215 | ), |
216 | 216 | ), |
217 | 217 | 'saved_cards' => array( |
218 | - 'title' => __( 'Saved Cards', 'woocommerce-gateway-stripe' ), |
|
219 | - 'label' => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ), |
|
218 | + 'title' => __('Saved Cards', 'woocommerce-gateway-stripe'), |
|
219 | + 'label' => __('Enable Payment via Saved Cards', 'woocommerce-gateway-stripe'), |
|
220 | 220 | 'type' => 'checkbox', |
221 | - 'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ), |
|
221 | + 'description' => __('If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe'), |
|
222 | 222 | 'default' => 'yes', |
223 | 223 | 'desc_tip' => true, |
224 | 224 | ), |
225 | 225 | 'logging' => array( |
226 | - 'title' => __( 'Logging', 'woocommerce-gateway-stripe' ), |
|
227 | - 'label' => __( 'Log debug messages', 'woocommerce-gateway-stripe' ), |
|
226 | + 'title' => __('Logging', 'woocommerce-gateway-stripe'), |
|
227 | + 'label' => __('Log debug messages', 'woocommerce-gateway-stripe'), |
|
228 | 228 | 'type' => 'checkbox', |
229 | - 'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ), |
|
229 | + 'description' => __('Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe'), |
|
230 | 230 | 'default' => 'no', |
231 | 231 | 'desc_tip' => true, |
232 | 232 | ), |