@@ -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.5.1' ); |
|
| 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.0' ); |
|
| 29 | -define( 'WC_STRIPE_MAIN_FILE', __FILE__ ); |
|
| 30 | -define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
|
| 31 | -define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
| 25 | +define('WC_STRIPE_VERSION', '4.5.1'); |
|
| 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.0'); |
|
| 29 | +define('WC_STRIPE_MAIN_FILE', __FILE__); |
|
| 30 | +define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
|
| 31 | +define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
| 32 | 32 | |
| 33 | 33 | // 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,7 +51,7 @@ 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 | /** |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | 63 | function woocommerce_stripe_wc_country_not_supported() { |
| 64 | - echo '<div class="error"><p><strong>' . __( 'Stripe is not available in your store\'s country and will not be available for buyers to choose during checkout.', 'woocommerce-gateway-stripe' ) . '</strong></p></div>'; |
|
| 64 | + echo '<div class="error"><p><strong>' . __('Stripe is not available in your store\'s country and will not be available for buyers to choose during checkout.', 'woocommerce-gateway-stripe') . '</strong></p></div>'; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @return bool |
| 73 | 73 | */ |
| 74 | 74 | function woocommerce_stripe_wc_country_is_supported_country() { |
| 75 | - $wc_default_country = substr( get_option( 'woocommerce_default_country' ), 0, 2 ); |
|
| 75 | + $wc_default_country = substr(get_option('woocommerce_default_country'), 0, 2); |
|
| 76 | 76 | |
| 77 | 77 | $supported_countries = apply_filters( |
| 78 | 78 | 'wc_stripe_supported_countries', |
@@ -118,30 +118,30 @@ discard block |
||
| 118 | 118 | ) |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | - return in_array( $wc_default_country, $supported_countries ); |
|
| 121 | + return in_array($wc_default_country, $supported_countries); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | -add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' ); |
|
| 124 | +add_action('plugins_loaded', 'woocommerce_gateway_stripe_init'); |
|
| 125 | 125 | |
| 126 | 126 | function woocommerce_gateway_stripe_init() { |
| 127 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
| 127 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
| 128 | 128 | |
| 129 | - if ( ! class_exists( 'WooCommerce' ) ) { |
|
| 130 | - add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' ); |
|
| 129 | + if ( ! class_exists('WooCommerce')) { |
|
| 130 | + add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice'); |
|
| 131 | 131 | return; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ( version_compare( WC_VERSION, WC_STRIPE_MIN_WC_VER, '<' ) ) { |
|
| 135 | - add_action( 'admin_notices', 'woocommerce_stripe_wc_not_supported' ); |
|
| 134 | + if (version_compare(WC_VERSION, WC_STRIPE_MIN_WC_VER, '<')) { |
|
| 135 | + add_action('admin_notices', 'woocommerce_stripe_wc_not_supported'); |
|
| 136 | 136 | return; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ( ! woocommerce_stripe_wc_country_is_supported_country() ) { |
|
| 140 | - add_action( 'admin_notices', 'woocommerce_stripe_wc_country_not_supported' ); |
|
| 139 | + if ( ! woocommerce_stripe_wc_country_is_supported_country()) { |
|
| 140 | + add_action('admin_notices', 'woocommerce_stripe_wc_country_not_supported'); |
|
| 141 | 141 | return; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if ( ! class_exists( 'WC_Stripe' ) ) : |
|
| 144 | + if ( ! class_exists('WC_Stripe')) : |
|
| 145 | 145 | |
| 146 | 146 | class WC_Stripe { |
| 147 | 147 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @return Singleton The *Singleton* instance. |
| 157 | 157 | */ |
| 158 | 158 | public static function get_instance() { |
| 159 | - if ( null === self::$instance ) { |
|
| 159 | + if (null === self::$instance) { |
|
| 160 | 160 | self::$instance = new self(); |
| 161 | 161 | } |
| 162 | 162 | return self::$instance; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * *Singleton* via the `new` operator from outside of this class. |
| 184 | 184 | */ |
| 185 | 185 | private function __construct() { |
| 186 | - add_action( 'admin_init', array( $this, 'install' ) ); |
|
| 186 | + add_action('admin_init', array($this, 'install')); |
|
| 187 | 187 | $this->init(); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -194,55 +194,55 @@ discard block |
||
| 194 | 194 | * @version 4.0.0 |
| 195 | 195 | */ |
| 196 | 196 | public function init() { |
| 197 | - if ( is_admin() ) { |
|
| 198 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
| 197 | + if (is_admin()) { |
|
| 198 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php'; |
|
| 202 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php'; |
|
| 203 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php'; |
|
| 204 | - include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php'; |
|
| 205 | - require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
| 206 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
| 207 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
| 208 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
| 209 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
| 210 | - require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php'; |
|
| 211 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
| 212 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-checkout.php'; |
|
| 213 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
| 214 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
| 215 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
| 216 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
| 217 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
| 218 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
| 219 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
| 220 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
| 221 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
| 222 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
| 223 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
| 224 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php'; |
|
| 225 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
| 226 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php'; |
|
| 227 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php'; |
|
| 228 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-session.php'; |
|
| 229 | - |
|
| 230 | - if ( is_admin() ) { |
|
| 231 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
| 201 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php'; |
|
| 202 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'; |
|
| 203 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'; |
|
| 204 | + include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php'; |
|
| 205 | + require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
| 206 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
| 207 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
| 208 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
| 209 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
| 210 | + require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'; |
|
| 211 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
| 212 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-checkout.php'; |
|
| 213 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
| 214 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
| 215 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
| 216 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
| 217 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
| 218 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
| 219 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
| 220 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
| 221 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
| 222 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
| 223 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
| 224 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'; |
|
| 225 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
| 226 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'; |
|
| 227 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php'; |
|
| 228 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-session.php'; |
|
| 229 | + |
|
| 230 | + if (is_admin()) { |
|
| 231 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // REMOVE IN THE FUTURE. |
| 235 | - require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
| 235 | + require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
| 236 | 236 | |
| 237 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
| 238 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
| 239 | - add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 ); |
|
| 237 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
| 238 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
| 239 | + add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2); |
|
| 240 | 240 | |
| 241 | 241 | // Modify emails emails. |
| 242 | - add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 ); |
|
| 242 | + add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20); |
|
| 243 | 243 | |
| 244 | - if ( version_compare( WC_VERSION, '3.4', '<' ) ) { |
|
| 245 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
| 244 | + if (version_compare(WC_VERSION, '3.4', '<')) { |
|
| 245 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | * @version 4.0.0 |
| 254 | 254 | */ |
| 255 | 255 | public function update_plugin_version() { |
| 256 | - delete_option( 'wc_stripe_version' ); |
|
| 257 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
| 256 | + delete_option('wc_stripe_version'); |
|
| 257 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -264,15 +264,15 @@ discard block |
||
| 264 | 264 | * @version 3.1.0 |
| 265 | 265 | */ |
| 266 | 266 | public function install() { |
| 267 | - if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
| 267 | + if ( ! is_plugin_active(plugin_basename(__FILE__))) { |
|
| 268 | 268 | return; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
| 272 | - do_action( 'woocommerce_stripe_updated' ); |
|
| 271 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
| 272 | + do_action('woocommerce_stripe_updated'); |
|
| 273 | 273 | |
| 274 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
| 275 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
| 274 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
| 275 | + define('WC_STRIPE_INSTALLING', true); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | $this->update_plugin_version(); |
@@ -285,11 +285,11 @@ discard block |
||
| 285 | 285 | * @since 1.0.0 |
| 286 | 286 | * @version 4.0.0 |
| 287 | 287 | */ |
| 288 | - public function plugin_action_links( $links ) { |
|
| 288 | + public function plugin_action_links($links) { |
|
| 289 | 289 | $plugin_links = array( |
| 290 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
| 290 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
| 291 | 291 | ); |
| 292 | - return array_merge( $plugin_links, $links ); |
|
| 292 | + return array_merge($plugin_links, $links); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | * @param string $file Name of current file. |
| 301 | 301 | * @return array $links Update list of plugin links. |
| 302 | 302 | */ |
| 303 | - public function plugin_row_meta( $links, $file ) { |
|
| 304 | - if ( plugin_basename( __FILE__ ) === $file ) { |
|
| 303 | + public function plugin_row_meta($links, $file) { |
|
| 304 | + if (plugin_basename(__FILE__) === $file) { |
|
| 305 | 305 | $row_meta = array( |
| 306 | - '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>', |
|
| 307 | - '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>', |
|
| 306 | + '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>', |
|
| 307 | + '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>', |
|
| 308 | 308 | ); |
| 309 | - return array_merge( $links, $row_meta ); |
|
| 309 | + return array_merge($links, $row_meta); |
|
| 310 | 310 | } |
| 311 | 311 | return (array) $links; |
| 312 | 312 | } |
@@ -317,8 +317,8 @@ discard block |
||
| 317 | 317 | * @since 1.0.0 |
| 318 | 318 | * @version 4.0.0 |
| 319 | 319 | */ |
| 320 | - public function add_gateways( $methods ) { |
|
| 321 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) { |
|
| 320 | + public function add_gateways($methods) { |
|
| 321 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) { |
|
| 322 | 322 | $methods[] = 'WC_Stripe_Subs_Compat'; |
| 323 | 323 | $methods[] = 'WC_Stripe_Sepa_Subs_Compat'; |
| 324 | 324 | } else { |
@@ -345,28 +345,28 @@ discard block |
||
| 345 | 345 | * @since 4.0.0 |
| 346 | 346 | * @version 4.0.0 |
| 347 | 347 | */ |
| 348 | - public function filter_gateway_order_admin( $sections ) { |
|
| 349 | - unset( $sections['stripe'] ); |
|
| 350 | - unset( $sections['stripe_bancontact'] ); |
|
| 351 | - unset( $sections['stripe_sofort'] ); |
|
| 352 | - unset( $sections['stripe_giropay'] ); |
|
| 353 | - unset( $sections['stripe_eps'] ); |
|
| 354 | - unset( $sections['stripe_ideal'] ); |
|
| 355 | - unset( $sections['stripe_p24'] ); |
|
| 356 | - unset( $sections['stripe_alipay'] ); |
|
| 357 | - unset( $sections['stripe_sepa'] ); |
|
| 358 | - unset( $sections['stripe_multibanco'] ); |
|
| 348 | + public function filter_gateway_order_admin($sections) { |
|
| 349 | + unset($sections['stripe']); |
|
| 350 | + unset($sections['stripe_bancontact']); |
|
| 351 | + unset($sections['stripe_sofort']); |
|
| 352 | + unset($sections['stripe_giropay']); |
|
| 353 | + unset($sections['stripe_eps']); |
|
| 354 | + unset($sections['stripe_ideal']); |
|
| 355 | + unset($sections['stripe_p24']); |
|
| 356 | + unset($sections['stripe_alipay']); |
|
| 357 | + unset($sections['stripe_sepa']); |
|
| 358 | + unset($sections['stripe_multibanco']); |
|
| 359 | 359 | |
| 360 | 360 | $sections['stripe'] = 'Stripe'; |
| 361 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
| 362 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
| 363 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
| 364 | - $sections['stripe_eps'] = __( 'Stripe EPS', 'woocommerce-gateway-stripe' ); |
|
| 365 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
| 366 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
| 367 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
| 368 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
| 369 | - $sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' ); |
|
| 361 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
| 362 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
| 363 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
| 364 | + $sections['stripe_eps'] = __('Stripe EPS', 'woocommerce-gateway-stripe'); |
|
| 365 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
| 366 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
| 367 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
| 368 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
| 369 | + $sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe'); |
|
| 370 | 370 | |
| 371 | 371 | return $sections; |
| 372 | 372 | } |
@@ -377,16 +377,16 @@ discard block |
||
| 377 | 377 | * @param WC_Email[] $email_classes All existing emails. |
| 378 | 378 | * @return WC_Email[] |
| 379 | 379 | */ |
| 380 | - public function add_emails( $email_classes ) { |
|
| 380 | + public function add_emails($email_classes) { |
|
| 381 | 381 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php'; |
| 382 | 382 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php'; |
| 383 | 383 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php'; |
| 384 | 384 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication-retry.php'; |
| 385 | 385 | |
| 386 | 386 | // Add all emails, generated by the gateway. |
| 387 | - $email_classes['WC_Stripe_Email_Failed_Renewal_Authentication'] = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes ); |
|
| 388 | - $email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes ); |
|
| 389 | - $email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry( $email_classes ); |
|
| 387 | + $email_classes['WC_Stripe_Email_Failed_Renewal_Authentication'] = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes); |
|
| 388 | + $email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes); |
|
| 389 | + $email_classes['WC_Stripe_Email_Failed_Authentication_Retry'] = new WC_Stripe_Email_Failed_Authentication_Retry($email_classes); |
|
| 390 | 390 | |
| 391 | 391 | return $email_classes; |
| 392 | 392 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -7,28 +7,28 @@ discard block |
||
| 7 | 7 | 'wc_stripe_checkout_settings', |
| 8 | 8 | array( |
| 9 | 9 | 'enabled' => array( |
| 10 | - 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ), |
|
| 11 | - 'label' => __( 'Enable Stripe Checkout', 'woocommerce-gateway-stripe' ), |
|
| 10 | + 'title' => __('Enable/Disable', 'woocommerce-gateway-stripe'), |
|
| 11 | + 'label' => __('Enable Stripe Checkout', 'woocommerce-gateway-stripe'), |
|
| 12 | 12 | 'type' => 'checkbox', |
| 13 | 13 | 'description' => '', |
| 14 | 14 | 'default' => 'no', |
| 15 | 15 | ), |
| 16 | 16 | 'title' => array( |
| 17 | - 'title' => __( 'Title', 'woocommerce-gateway-stripe' ), |
|
| 17 | + 'title' => __('Title', 'woocommerce-gateway-stripe'), |
|
| 18 | 18 | 'type' => 'text', |
| 19 | - 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
| 20 | - 'default' => __( 'Bancontact', 'woocommerce-gateway-stripe' ), |
|
| 19 | + 'description' => __('This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
| 20 | + 'default' => __('Bancontact', 'woocommerce-gateway-stripe'), |
|
| 21 | 21 | 'desc_tip' => true, |
| 22 | 22 | ), |
| 23 | 23 | 'description' => array( |
| 24 | - 'title' => __( 'Description', 'woocommerce-gateway-stripe' ), |
|
| 24 | + 'title' => __('Description', 'woocommerce-gateway-stripe'), |
|
| 25 | 25 | 'type' => 'text', |
| 26 | - 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ), |
|
| 27 | - 'default' => __( 'You will be redirected to Stripe.', 'woocommerce-gateway-stripe' ), |
|
| 26 | + 'description' => __('This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe'), |
|
| 27 | + 'default' => __('You will be redirected to Stripe.', 'woocommerce-gateway-stripe'), |
|
| 28 | 28 | 'desc_tip' => true, |
| 29 | 29 | ), |
| 30 | 30 | 'webhook' => array( |
| 31 | - 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), |
|
| 31 | + 'title' => __('Webhook Endpoints', 'woocommerce-gateway-stripe'), |
|
| 32 | 32 | 'type' => 'title', |
| 33 | 33 | /* translators: webhook URL */ |
| 34 | 34 | 'description' => $this->display_admin_settings_webhook_description(), |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * Set the Stripe session ID. |
| 35 | 35 | * @param string $id Stripe session ID. |
| 36 | 36 | */ |
| 37 | - public function set_id( $id ) { |
|
| 38 | - $this->id = wc_clean( $id ); |
|
| 37 | + public function set_id($id) { |
|
| 38 | + $this->id = wc_clean($id); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | * @param array $args Additional arguments (optional). |
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | - protected function generate_session_request( $args = array() ) { |
|
| 47 | + protected function generate_session_request($args = array()) { |
|
| 48 | 48 | $defaults = [ |
| 49 | - 'payment_method_types' => [ 'card', 'ideal' ], |
|
| 49 | + 'payment_method_types' => ['card', 'ideal'], |
|
| 50 | 50 | 'line_items' => [ |
| 51 | 51 | [ |
| 52 | 52 | 'price_data' => [ |
@@ -64,25 +64,25 @@ discard block |
||
| 64 | 64 | 'cancel_url' => wc_get_checkout_url() |
| 65 | 65 | ]; |
| 66 | 66 | |
| 67 | - return wp_parse_args( $args, $defaults ); |
|
| 67 | + return wp_parse_args($args, $defaults); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Create a session via API. |
| 72 | 72 | * @return WP_Error|string Session ID |
| 73 | 73 | */ |
| 74 | - public function create_session( $args ) { |
|
| 75 | - error_log( 'in create_session' ); |
|
| 76 | - $args = $this->generate_session_request( $args ); |
|
| 77 | - $response = WC_Stripe_API::request( apply_filters( 'wc_stripe_create_session_args', $args ), 'checkout/sessions' ); |
|
| 74 | + public function create_session($args) { |
|
| 75 | + error_log('in create_session'); |
|
| 76 | + $args = $this->generate_session_request($args); |
|
| 77 | + $response = WC_Stripe_API::request(apply_filters('wc_stripe_create_session_args', $args), 'checkout/sessions'); |
|
| 78 | 78 | |
| 79 | - if ( ! empty( $response->error ) ) { |
|
| 80 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
| 79 | + if ( ! empty($response->error)) { |
|
| 80 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $this->set_id( $response->id ); |
|
| 83 | + $this->set_id($response->id); |
|
| 84 | 84 | |
| 85 | - do_action( 'woocommerce_stripe_add_customer', $args, $response ); |
|
| 85 | + do_action('woocommerce_stripe_add_customer', $args, $response); |
|
| 86 | 86 | |
| 87 | 87 | return $this->get_id(); |
| 88 | 88 | } |
@@ -94,27 +94,27 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @throws WC_Stripe_Exception |
| 96 | 96 | */ |
| 97 | - public function update_customer( $args = array() ) { |
|
| 98 | - if ( empty( $this->get_id() ) ) { |
|
| 99 | - throw new WC_Stripe_Exception( 'id_required_to_update_session', __( 'Attempting to update a Stripe session without a session ID.', 'woocommerce-gateway-stripe' ) ); |
|
| 97 | + public function update_customer($args = array()) { |
|
| 98 | + if (empty($this->get_id())) { |
|
| 99 | + throw new WC_Stripe_Exception('id_required_to_update_session', __('Attempting to update a Stripe session without a session ID.', 'woocommerce-gateway-stripe')); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $args = $this->generate_session_request( $args ); |
|
| 103 | - $args = apply_filters( 'wc_stripe_update_session_args', $args ); |
|
| 104 | - $response = WC_Stripe_API::request( $args, 'sessions/' . $this->get_id() ); |
|
| 102 | + $args = $this->generate_session_request($args); |
|
| 103 | + $args = apply_filters('wc_stripe_update_session_args', $args); |
|
| 104 | + $response = WC_Stripe_API::request($args, 'sessions/' . $this->get_id()); |
|
| 105 | 105 | |
| 106 | - if ( ! empty( $response->error ) ) { |
|
| 107 | - if ( $this->is_no_such_session_error( $response->error ) ) { |
|
| 106 | + if ( ! empty($response->error)) { |
|
| 107 | + if ($this->is_no_such_session_error($response->error)) { |
|
| 108 | 108 | // This can happen when switching the main Stripe account or importing users from another site. |
| 109 | 109 | // If not already retrying, recreate the customer and then try updating it again. |
| 110 | 110 | $this->recreate_session(); |
| 111 | - return $this->update_session( $args ); // TODO retry limit |
|
| 111 | + return $this->update_session($args); // TODO retry limit |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
| 114 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - do_action( 'woocommerce_stripe_update_session', $args, $response ); |
|
| 117 | + do_action('woocommerce_stripe_update_session', $args, $response); |
|
| 118 | 118 | |
| 119 | 119 | return $this->get_id(); |
| 120 | 120 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct() { |
| 32 | 32 | $this->id = 'stripe_checkout'; |
| 33 | - $this->method_title = __( 'Stripe Checkout', 'woocommerce-gateway-stripe' ); |
|
| 33 | + $this->method_title = __('Stripe Checkout', 'woocommerce-gateway-stripe'); |
|
| 34 | 34 | /* translators: link */ |
| 35 | - $this->method_description = sprintf( __( 'All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe' ), admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe' ) ); |
|
| 35 | + $this->method_description = sprintf(__('All other general Stripe settings can be adjusted <a href="%s">here</a>.', 'woocommerce-gateway-stripe'), admin_url('admin.php?page=wc-settings&tab=checkout§ion=stripe')); |
|
| 36 | 36 | $this->supports = array( |
| 37 | 37 | 'products', |
| 38 | 38 | 'refunds', |
@@ -44,20 +44,20 @@ discard block |
||
| 44 | 44 | // Load the settings. |
| 45 | 45 | $this->init_settings(); |
| 46 | 46 | |
| 47 | - $main_settings = get_option( 'woocommerce_stripe_settings' ); |
|
| 48 | - $this->title = $this->get_option( 'title' ); |
|
| 49 | - $this->description = $this->get_option( 'description' ); |
|
| 50 | - $this->enabled = $this->get_option( 'enabled' ); |
|
| 51 | - $this->testmode = ( ! empty( $main_settings['testmode'] ) && 'yes' === $main_settings['testmode'] ) ? true : false; |
|
| 52 | - $this->secret_key = ! empty( $main_settings['secret_key'] ) ? $main_settings['secret_key'] : ''; |
|
| 47 | + $main_settings = get_option('woocommerce_stripe_settings'); |
|
| 48 | + $this->title = $this->get_option('title'); |
|
| 49 | + $this->description = $this->get_option('description'); |
|
| 50 | + $this->enabled = $this->get_option('enabled'); |
|
| 51 | + $this->testmode = ( ! empty($main_settings['testmode']) && 'yes' === $main_settings['testmode']) ? true : false; |
|
| 52 | + $this->secret_key = ! empty($main_settings['secret_key']) ? $main_settings['secret_key'] : ''; |
|
| 53 | 53 | |
| 54 | - if ( $this->testmode ) { |
|
| 55 | - $this->publishable_key = ! empty( $main_settings['test_publishable_key'] ) ? $main_settings['test_publishable_key'] : ''; |
|
| 56 | - $this->secret_key = ! empty( $main_settings['test_secret_key'] ) ? $main_settings['test_secret_key'] : ''; |
|
| 54 | + if ($this->testmode) { |
|
| 55 | + $this->publishable_key = ! empty($main_settings['test_publishable_key']) ? $main_settings['test_publishable_key'] : ''; |
|
| 56 | + $this->secret_key = ! empty($main_settings['test_secret_key']) ? $main_settings['test_secret_key'] : ''; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); |
|
| 60 | - add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); |
|
| 59 | + add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); |
|
| 60 | + add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | 85 | public function is_available() { |
| 86 | - if ( ! in_array( get_woocommerce_currency(), $this->get_supported_currency() ) ) { |
|
| 86 | + if ( ! in_array(get_woocommerce_currency(), $this->get_supported_currency())) { |
|
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -96,16 +96,16 @@ discard block |
||
| 96 | 96 | * @since 4.6.0 |
| 97 | 97 | */ |
| 98 | 98 | public function init_form_fields() { |
| 99 | - $this->form_fields = require( WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-checkout-settings.php' ); |
|
| 99 | + $this->form_fields = require(WC_STRIPE_PLUGIN_PATH . '/includes/admin/stripe-checkout-settings.php'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public function payment_scripts() { |
| 103 | - if ( ! is_cart() && ! is_checkout() && ! isset( $_GET['pay_for_order'] ) && ! is_add_payment_method_page() ) { |
|
| 103 | + if ( ! is_cart() && ! is_checkout() && ! isset($_GET['pay_for_order']) && ! is_add_payment_method_page()) { |
|
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - wp_enqueue_style( 'stripe_styles' ); |
|
| 108 | - wp_enqueue_script( 'woocommerce_stripe' ); |
|
| 107 | + wp_enqueue_style('stripe_styles'); |
|
| 108 | + wp_enqueue_script('woocommerce_stripe'); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | // Request session from stripe. |
| 122 | 122 | $stripe_session = new WC_Stripe_Session(); |
| 123 | 123 | $stripe_session->create_session( |
| 124 | - [ 'success_url' => $this->get_return_url() ] |
|
| 124 | + ['success_url' => $this->get_return_url()] |
|
| 125 | 125 | ); |
| 126 | 126 | |
| 127 | - echo '<div id="stripe-checkout-data" data-secret="' . esc_attr( $stripe_session->get_id() ) . '"></div>'; |
|
| 127 | + echo '<div id="stripe-checkout-data" data-secret="' . esc_attr($stripe_session->get_id()) . '"></div>'; |
|
| 128 | 128 | |
| 129 | - if ( $description ) { |
|
| 130 | - echo apply_filters( 'wc_stripe_description', wpautop( wp_kses_post( $description ) ), $this->id ); |
|
| 129 | + if ($description) { |
|
| 130 | + echo apply_filters('wc_stripe_description', wpautop(wp_kses_post($description)), $this->id); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | } |