@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | public $saved_cards; |
12 | 12 | |
13 | 13 | public function __construct() { |
14 | - $this->saved_cards = WC_Stripe_Helper::get_settings( 'stripe', 'saved_cards' ); |
|
14 | + $this->saved_cards = WC_Stripe_Helper::get_settings('stripe', 'saved_cards'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -19,68 +19,68 @@ discard block |
||
19 | 19 | * @param int $order_id |
20 | 20 | * @return boolean |
21 | 21 | */ |
22 | - public function is_pre_order( $order_id ) { |
|
23 | - return WC_Pre_Orders_Order::order_contains_pre_order( $order_id ); |
|
22 | + public function is_pre_order($order_id) { |
|
23 | + return WC_Pre_Orders_Order::order_contains_pre_order($order_id); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Remove order meta |
28 | 28 | * @param object $order |
29 | 29 | */ |
30 | - public function remove_order_source_before_retry( $order ) { |
|
31 | - $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
32 | - delete_post_meta( $order_id, '_stripe_source_id' ); |
|
30 | + public function remove_order_source_before_retry($order) { |
|
31 | + $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
32 | + delete_post_meta($order_id, '_stripe_source_id'); |
|
33 | 33 | // For BW compat will remove in the future. |
34 | - delete_post_meta( $order_id, '_stripe_card_id' ); |
|
34 | + delete_post_meta($order_id, '_stripe_card_id'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Remove order meta |
39 | 39 | * @param object $order |
40 | 40 | */ |
41 | - public function remove_order_customer_before_retry( $order ) { |
|
42 | - $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
43 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
41 | + public function remove_order_customer_before_retry($order) { |
|
42 | + $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
43 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Process the pre-order when pay upon release is used. |
48 | 48 | * @param int $order_id |
49 | 49 | */ |
50 | - public function process_pre_order( $order_id ) { |
|
50 | + public function process_pre_order($order_id) { |
|
51 | 51 | try { |
52 | - $order = wc_get_order( $order_id ); |
|
52 | + $order = wc_get_order($order_id); |
|
53 | 53 | |
54 | 54 | // This will throw exception if not valid. |
55 | - $this->validate_minimum_order_amount( $order ); |
|
55 | + $this->validate_minimum_order_amount($order); |
|
56 | 56 | |
57 | - $prepared_source = $this->prepare_source( get_current_user_id(), true ); |
|
57 | + $prepared_source = $this->prepare_source(get_current_user_id(), true); |
|
58 | 58 | |
59 | 59 | // We need a source on file to continue. |
60 | - if ( empty( $prepared_source->customer ) || empty( $prepared_source->source ) ) { |
|
61 | - throw new WC_Stripe_Exception( __( 'Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe' ) ); |
|
60 | + if (empty($prepared_source->customer) || empty($prepared_source->source)) { |
|
61 | + throw new WC_Stripe_Exception(__('Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe')); |
|
62 | 62 | } |
63 | 63 | |
64 | - $this->save_source_to_order( $order, $prepared_source ); |
|
64 | + $this->save_source_to_order($order, $prepared_source); |
|
65 | 65 | |
66 | 66 | // Remove cart |
67 | 67 | WC()->cart->empty_cart(); |
68 | 68 | |
69 | 69 | // Is pre ordered! |
70 | - WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order ); |
|
70 | + WC_Pre_Orders_Order::mark_order_as_pre_ordered($order); |
|
71 | 71 | |
72 | 72 | // Return thank you page redirect |
73 | 73 | return array( |
74 | 74 | 'result' => 'success', |
75 | - 'redirect' => $this->get_return_url( $order ), |
|
75 | + 'redirect' => $this->get_return_url($order), |
|
76 | 76 | ); |
77 | - } catch ( WC_Stripe_Exception $e ) { |
|
78 | - wc_add_notice( $e->getLocalizedMessage(), 'error' ); |
|
79 | - WC_Stripe_Logger::log( 'Pre Orders Error: ' . $e->getMessage() ); |
|
77 | + } catch (WC_Stripe_Exception $e) { |
|
78 | + wc_add_notice($e->getLocalizedMessage(), 'error'); |
|
79 | + WC_Stripe_Logger::log('Pre Orders Error: ' . $e->getMessage()); |
|
80 | 80 | |
81 | 81 | return array( |
82 | 82 | 'result' => 'success', |
83 | - 'redirect' => $order->get_checkout_payment_url( true ), |
|
83 | + 'redirect' => $order->get_checkout_payment_url(true), |
|
84 | 84 | ); |
85 | 85 | } |
86 | 86 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param WC_Order $order |
91 | 91 | * @return void |
92 | 92 | */ |
93 | - public function process_pre_order_release_payment( $order ) { |
|
93 | + public function process_pre_order_release_payment($order) { |
|
94 | 94 | try { |
95 | 95 | // Define some callbacks if the first attempt fails. |
96 | 96 | $retry_callbacks = array( |
@@ -98,41 +98,41 @@ discard block |
||
98 | 98 | 'remove_order_customer_before_retry', |
99 | 99 | ); |
100 | 100 | |
101 | - while ( 1 ) { |
|
102 | - $source = $this->prepare_order_source( $order ); |
|
103 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) ); |
|
101 | + while (1) { |
|
102 | + $source = $this->prepare_order_source($order); |
|
103 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $source)); |
|
104 | 104 | |
105 | - if ( ! empty( $response->error ) ) { |
|
106 | - if ( 'card_error' === $response->error->type && 'authentication_required' === $response->error->decline_code ) { |
|
105 | + if ( ! empty($response->error)) { |
|
106 | + if ('card_error' === $response->error->type && 'authentication_required' === $response->error->decline_code) { |
|
107 | 107 | WC_Emails::instance(); |
108 | 108 | |
109 | - do_action( 'wc_gateway_stripe_process_payment_authentication_required', $order ); |
|
109 | + do_action('wc_gateway_stripe_process_payment_authentication_required', $order); |
|
110 | 110 | |
111 | - throw new WC_Stripe_Exception( print_r( $response, true ), $response->error->message ); |
|
111 | + throw new WC_Stripe_Exception(print_r($response, true), $response->error->message); |
|
112 | 112 | } |
113 | 113 | |
114 | - if ( 0 === sizeof( $retry_callbacks ) ) { |
|
115 | - throw new Exception( $response->error->message ); |
|
114 | + if (0 === sizeof($retry_callbacks)) { |
|
115 | + throw new Exception($response->error->message); |
|
116 | 116 | } else { |
117 | - $retry_callback = array_shift( $retry_callbacks ); |
|
118 | - call_user_func( array( $this, $retry_callback ), $order ); |
|
117 | + $retry_callback = array_shift($retry_callbacks); |
|
118 | + call_user_func(array($this, $retry_callback), $order); |
|
119 | 119 | } |
120 | 120 | } else { |
121 | 121 | // Successful |
122 | - $this->process_response( $response, $order ); |
|
122 | + $this->process_response($response, $order); |
|
123 | 123 | break; |
124 | 124 | } |
125 | 125 | } |
126 | - } catch ( Exception $e ) { |
|
126 | + } catch (Exception $e) { |
|
127 | 127 | /* translators: error message */ |
128 | - $order_note = sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $e->getMessage() ); |
|
128 | + $order_note = sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $e->getMessage()); |
|
129 | 129 | |
130 | 130 | // Mark order as failed if not already set, |
131 | 131 | // otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times |
132 | - if ( ! $order->has_status( 'failed' ) ) { |
|
133 | - $order->update_status( 'failed', $order_note ); |
|
132 | + if ( ! $order->has_status('failed')) { |
|
133 | + $order->update_status('failed', $order_note); |
|
134 | 134 | } else { |
135 | - $order->add_order_note( $order_note ); |
|
135 | + $order->add_order_note($order_note); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly. |
4 | 4 | } |
5 | 5 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | 'email_heading' => $this->get_heading(), |
31 | 31 | 'sent_to_admin' => false, |
32 | 32 | 'plain_text' => false, |
33 | - 'authorization_url' => $this->get_authorization_url( $this->object ), |
|
33 | + 'authorization_url' => $this->get_authorization_url($this->object), |
|
34 | 34 | 'email' => $this, |
35 | 35 | ), |
36 | 36 | '', |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'email_heading' => $this->get_heading(), |
54 | 54 | 'sent_to_admin' => false, |
55 | 55 | 'plain_text' => true, |
56 | - 'authorization_url' => $this->get_authorization_url( $this->object ), |
|
56 | + 'authorization_url' => $this->get_authorization_url($this->object), |
|
57 | 57 | 'email' => $this, |
58 | 58 | ), |
59 | 59 | '', |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param WC_Order $order The order whose payment needs authentication. |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - public function get_authorization_url( $order ) { |
|
72 | - return add_query_arg( 'wc-stripe-confirmation', 1, $order->get_checkout_payment_url( false ) ); |
|
71 | + public function get_authorization_url($order) { |
|
72 | + return add_query_arg('wc-stripe-confirmation', 1, $order->get_checkout_payment_url(false)); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | $this->form_fields = array( |
83 | 83 | 'enabled' => array( |
84 | - 'title' => _x( 'Enable/Disable', 'an email notification', 'woocommerce-gateway-stripe' ), |
|
84 | + 'title' => _x('Enable/Disable', 'an email notification', 'woocommerce-gateway-stripe'), |
|
85 | 85 | 'type' => 'checkbox', |
86 | - 'label' => __( 'Enable this email notification', 'woocommerce-gateway-stripe' ), |
|
86 | + 'label' => __('Enable this email notification', 'woocommerce-gateway-stripe'), |
|
87 | 87 | 'default' => 'yes', |
88 | 88 | ), |
89 | 89 | |
@@ -98,29 +98,29 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @param WC_Order $order The renewal order whose payment failed. |
100 | 100 | */ |
101 | - public function trigger( $order ) { |
|
102 | - if ( ! $this->is_enabled() ) { |
|
101 | + public function trigger($order) { |
|
102 | + if ( ! $this->is_enabled()) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->object = $order; |
107 | 107 | |
108 | - if ( method_exists( $order, 'get_billing_email' ) ) { |
|
108 | + if (method_exists($order, 'get_billing_email')) { |
|
109 | 109 | $this->recipient = $order->get_billing_email(); |
110 | 110 | } else { |
111 | 111 | $this->recipient = $order->billing_email; |
112 | 112 | } |
113 | 113 | |
114 | 114 | $this->find['order_date'] = '{order_date}'; |
115 | - if ( function_exists( 'wc_format_datetime' ) ) { // WC 3.0+ |
|
116 | - $this->replace['order_date'] = wc_format_datetime( $order->get_date_created() ); |
|
115 | + if (function_exists('wc_format_datetime')) { // WC 3.0+ |
|
116 | + $this->replace['order_date'] = wc_format_datetime($order->get_date_created()); |
|
117 | 117 | } else { // WC < 3.0 |
118 | - $this->replace['order_date'] = $order->date_created->date_i18n( wc_date_format() ); |
|
118 | + $this->replace['order_date'] = $order->date_created->date_i18n(wc_date_format()); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $this->find['order_number'] = '{order_number}'; |
122 | 122 | $this->replace['order_number'] = $order->get_order_number(); |
123 | 123 | |
124 | - $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); |
|
124 | + $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); |
|
125 | 125 | } |
126 | 126 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly. |
4 | 4 | } |
5 | 5 | |
@@ -14,20 +14,20 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @param WC_Email[] $email_classes All existing instances of WooCommerce emails. |
16 | 16 | */ |
17 | - public function __construct( $email_classes = array() ) { |
|
17 | + public function __construct($email_classes = array()) { |
|
18 | 18 | $this->id = 'failed_preorder_sca_authentication'; |
19 | - $this->title = __( 'Pre-order Payment Action Needed', 'woocommerce-gateway-stripe' ); |
|
20 | - $this->description = __( 'This is an order notification sent to the customer once a pre-order is complete, but additional payment steps are required.', 'woocommerce-gateway-stripe' ); |
|
19 | + $this->title = __('Pre-order Payment Action Needed', 'woocommerce-gateway-stripe'); |
|
20 | + $this->description = __('This is an order notification sent to the customer once a pre-order is complete, but additional payment steps are required.', 'woocommerce-gateway-stripe'); |
|
21 | 21 | $this->customer_email = true; |
22 | 22 | |
23 | 23 | $this->template_html = 'emails/failed-preorder-authentication.php'; |
24 | 24 | $this->template_plain = 'emails/plain/failed-preorder-authentication.php'; |
25 | - $this->template_base = plugin_dir_path( WC_STRIPE_MAIN_FILE ) . 'templates/'; |
|
25 | + $this->template_base = plugin_dir_path(WC_STRIPE_MAIN_FILE) . 'templates/'; |
|
26 | 26 | |
27 | 27 | // Triggers the email at the correct hook. |
28 | - add_action( 'wc_gateway_stripe_process_payment_authentication_required', array( $this, 'trigger' ), 10, 2 ); |
|
28 | + add_action('wc_gateway_stripe_process_payment_authentication_required', array($this, 'trigger'), 10, 2); |
|
29 | 29 | |
30 | - if ( isset( $email_classes['WC_Pre_Orders_Email_Pre_Order_Available'] ) ) { |
|
30 | + if (isset($email_classes['WC_Pre_Orders_Email_Pre_Order_Available'])) { |
|
31 | 31 | $this->original_email = $email_classes['WC_Pre_Orders_Email_Pre_Order_Available']; |
32 | 32 | } |
33 | 33 | |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param WC_Order $order The order that is being paid. |
42 | 42 | */ |
43 | - public function trigger( $order ) { |
|
44 | - if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order->get_id() ) ) { |
|
45 | - parent::trigger( $order ); |
|
43 | + public function trigger($order) { |
|
44 | + if (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Order::order_contains_pre_order($order->get_id())) { |
|
45 | + parent::trigger($order); |
|
46 | 46 | |
47 | - if ( isset( $this->original_email ) ) { |
|
48 | - remove_action( 'wc_pre_order_status_completed_notification', array( $this->original_email, 'trigger' ), 10, 2 ); |
|
47 | + if (isset($this->original_email)) { |
|
48 | + remove_action('wc_pre_order_status_completed_notification', array($this->original_email, 'trigger'), 10, 2); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return string |
57 | 57 | */ |
58 | 58 | public function get_default_subject() { |
59 | - return __( 'Payment authorization needed for pre-order {order_number}', 'woocommerce-gateway-stripe' ); |
|
59 | + return __('Payment authorization needed for pre-order {order_number}', 'woocommerce-gateway-stripe'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -65,6 +65,6 @@ discard block |
||
65 | 65 | * @return string |
66 | 66 | */ |
67 | 67 | public function get_default_heading() { |
68 | - return __( 'Payment authorization needed for pre-order {order_number}', 'woocommerce-gateway-stripe' ); |
|
68 | + return __('Payment authorization needed for pre-order {order_number}', 'woocommerce-gateway-stripe'); |
|
69 | 69 | } |
70 | 70 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly. |
4 | 4 | } |
5 | 5 | |
@@ -14,20 +14,20 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @param WC_Email[] $email_classes All existing instances of WooCommerce emails. |
16 | 16 | */ |
17 | - public function __construct( $email_classes = array() ) { |
|
17 | + public function __construct($email_classes = array()) { |
|
18 | 18 | $this->id = 'failed_renewal_authentication'; |
19 | - $this->title = __( 'Failed Subscription Renewal SCA Authentication', 'woocommerce-gateway-stripe' ); |
|
20 | - $this->description = __( 'Sent to a customer when a renewal fails because the transaction requires an SCA verification. The email contains renewal order information and payment links.', 'woocommerce-gateway-stripe' ); |
|
19 | + $this->title = __('Failed Subscription Renewal SCA Authentication', 'woocommerce-gateway-stripe'); |
|
20 | + $this->description = __('Sent to a customer when a renewal fails because the transaction requires an SCA verification. The email contains renewal order information and payment links.', 'woocommerce-gateway-stripe'); |
|
21 | 21 | $this->customer_email = true; |
22 | 22 | |
23 | 23 | $this->template_html = 'emails/failed-renewal-authentication.php'; |
24 | 24 | $this->template_plain = 'emails/plain/failed-renewal-authentication.php'; |
25 | - $this->template_base = plugin_dir_path( WC_STRIPE_MAIN_FILE ) . 'templates/'; |
|
25 | + $this->template_base = plugin_dir_path(WC_STRIPE_MAIN_FILE) . 'templates/'; |
|
26 | 26 | |
27 | 27 | // Triggers the email at the correct hook. |
28 | - add_action( 'wc_gateway_stripe_process_payment_authentication_required', array( $this, 'trigger' ) ); |
|
28 | + add_action('wc_gateway_stripe_process_payment_authentication_required', array($this, 'trigger')); |
|
29 | 29 | |
30 | - if ( isset( $email_classes['WCS_Email_Customer_Renewal_Invoice'] ) ) { |
|
30 | + if (isset($email_classes['WCS_Email_Customer_Renewal_Invoice'])) { |
|
31 | 31 | $this->original_email = $email_classes['WCS_Email_Customer_Renewal_Invoice']; |
32 | 32 | } |
33 | 33 | |
@@ -40,18 +40,18 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param WC_Order $order The order that is being paid. |
42 | 42 | */ |
43 | - public function trigger( $order ) { |
|
44 | - if ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order->get_id() ) || wcs_is_subscription( $order->get_id() ) || wcs_order_contains_renewal( $order->get_id() ) ) ) { |
|
45 | - parent::trigger( $order ); |
|
43 | + public function trigger($order) { |
|
44 | + if (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order->get_id()) || wcs_is_subscription($order->get_id()) || wcs_order_contains_renewal($order->get_id()))) { |
|
45 | + parent::trigger($order); |
|
46 | 46 | |
47 | 47 | // Prevent the renewal email from WooCommerce Subscriptions from being sent. |
48 | - if ( isset( $this->original_email ) ) { |
|
49 | - remove_action( 'woocommerce_generated_manual_renewal_order_renewal_notification', array( $this->original_email, 'trigger' ) ); |
|
50 | - remove_action( 'woocommerce_order_status_failed_renewal_notification', array( $this->original_email, 'trigger' ) ); |
|
48 | + if (isset($this->original_email)) { |
|
49 | + remove_action('woocommerce_generated_manual_renewal_order_renewal_notification', array($this->original_email, 'trigger')); |
|
50 | + remove_action('woocommerce_order_status_failed_renewal_notification', array($this->original_email, 'trigger')); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Prevent the retry email from WooCommerce Subscriptions from being sent. |
54 | - add_filter( 'wcs_get_retry_rule_raw', array( $this, 'prevent_retry_notification_email' ), 100, 3 ); |
|
54 | + add_filter('wcs_get_retry_rule_raw', array($this, 'prevent_retry_notification_email'), 100, 3); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return string |
62 | 62 | */ |
63 | 63 | public function get_default_subject() { |
64 | - return __( 'Payment authorization needed for renewal of {site_title} order {order_number}', 'woocommerce-gateway-stripe' ); |
|
64 | + return __('Payment authorization needed for renewal of {site_title} order {order_number}', 'woocommerce-gateway-stripe'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return string |
71 | 71 | */ |
72 | 72 | public function get_default_heading() { |
73 | - return __( 'Payment authorization needed for renewal of order {order_number}', 'woocommerce-gateway-stripe' ); |
|
73 | + return __('Payment authorization needed for renewal of order {order_number}', 'woocommerce-gateway-stripe'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @param int $order_id The ID of the order that needs payment. |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public function prevent_retry_notification_email( $rule_array, $retry_number, $order_id ) { |
|
85 | - if ( wcs_get_objects_property( $this->object, 'id' ) === $order_id ) { |
|
84 | + public function prevent_retry_notification_email($rule_array, $retry_number, $order_id) { |
|
85 | + if (wcs_get_objects_property($this->object, 'id') === $order_id) { |
|
86 | 86 | $rule_array['email_template_customer'] = ''; |
87 | 87 | } |
88 | 88 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | */ |
17 | 17 | |
18 | -if ( ! defined( 'ABSPATH' ) ) { |
|
18 | +if ( ! defined('ABSPATH')) { |
|
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | |
@@ -29,29 +29,29 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function woocommerce_stripe_missing_wc_notice() { |
31 | 31 | /* translators: 1. URL link. */ |
32 | - 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>'; |
|
32 | + 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>'; |
|
33 | 33 | } |
34 | 34 | |
35 | -add_action( 'plugins_loaded', 'woocommerce_gateway_stripe_init' ); |
|
35 | +add_action('plugins_loaded', 'woocommerce_gateway_stripe_init'); |
|
36 | 36 | |
37 | 37 | function woocommerce_gateway_stripe_init() { |
38 | - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
|
38 | + load_plugin_textdomain('woocommerce-gateway-stripe', false, plugin_basename(dirname(__FILE__)) . '/languages'); |
|
39 | 39 | |
40 | - if ( ! class_exists( 'WooCommerce' ) ) { |
|
41 | - add_action( 'admin_notices', 'woocommerce_stripe_missing_wc_notice' ); |
|
40 | + if ( ! class_exists('WooCommerce')) { |
|
41 | + add_action('admin_notices', 'woocommerce_stripe_missing_wc_notice'); |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | - if ( ! class_exists( 'WC_Stripe' ) ) : |
|
45 | + if ( ! class_exists('WC_Stripe')) : |
|
46 | 46 | /** |
47 | 47 | * Required minimums and constants |
48 | 48 | */ |
49 | - define( 'WC_STRIPE_VERSION', '4.2.5' ); |
|
50 | - define( 'WC_STRIPE_MIN_PHP_VER', '5.6.0' ); |
|
51 | - define( 'WC_STRIPE_MIN_WC_VER', '2.6.0' ); |
|
52 | - define( 'WC_STRIPE_MAIN_FILE', __FILE__ ); |
|
53 | - define( 'WC_STRIPE_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
|
54 | - define( 'WC_STRIPE_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
49 | + define('WC_STRIPE_VERSION', '4.2.5'); |
|
50 | + define('WC_STRIPE_MIN_PHP_VER', '5.6.0'); |
|
51 | + define('WC_STRIPE_MIN_WC_VER', '2.6.0'); |
|
52 | + define('WC_STRIPE_MAIN_FILE', __FILE__); |
|
53 | + define('WC_STRIPE_PLUGIN_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__)))); |
|
54 | + define('WC_STRIPE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
55 | 55 | |
56 | 56 | class WC_Stripe { |
57 | 57 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return Singleton The *Singleton* instance. |
67 | 67 | */ |
68 | 68 | public static function get_instance() { |
69 | - if ( null === self::$instance ) { |
|
69 | + if (null === self::$instance) { |
|
70 | 70 | self::$instance = new self(); |
71 | 71 | } |
72 | 72 | return self::$instance; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * *Singleton* via the `new` operator from outside of this class. |
94 | 94 | */ |
95 | 95 | private function __construct() { |
96 | - add_action( 'admin_init', array( $this, 'install' ) ); |
|
96 | + add_action('admin_init', array($this, 'install')); |
|
97 | 97 | $this->init(); |
98 | 98 | } |
99 | 99 | |
@@ -104,52 +104,52 @@ discard block |
||
104 | 104 | * @version 4.0.0 |
105 | 105 | */ |
106 | 106 | public function init() { |
107 | - if ( is_admin() ) { |
|
108 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
107 | + if (is_admin()) { |
|
108 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-privacy.php'; |
|
109 | 109 | } |
110 | 110 | |
111 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php'; |
|
112 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php'; |
|
113 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php'; |
|
114 | - include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php'; |
|
115 | - require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
116 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
117 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
118 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
119 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
120 | - require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php'; |
|
121 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
122 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
123 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
124 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
125 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
126 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
127 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
128 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
129 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
130 | - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
131 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
132 | - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
133 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php'; |
|
134 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
135 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php'; |
|
136 | - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php'; |
|
137 | - |
|
138 | - if ( is_admin() ) { |
|
139 | - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
111 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-exception.php'; |
|
112 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-logger.php'; |
|
113 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-helper.php'; |
|
114 | + include_once dirname(__FILE__) . '/includes/class-wc-stripe-api.php'; |
|
115 | + require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; |
|
116 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-webhook-handler.php'; |
|
117 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-sepa-payment-token.php'; |
|
118 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-apple-pay-registration.php'; |
|
119 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-pre-orders-compat.php'; |
|
120 | + require_once dirname(__FILE__) . '/includes/class-wc-gateway-stripe.php'; |
|
121 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; |
|
122 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; |
|
123 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; |
|
124 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; |
|
125 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; |
|
126 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; |
|
127 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; |
|
128 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; |
|
129 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; |
|
130 | + require_once dirname(__FILE__) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; |
|
131 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-subs-compat.php'; |
|
132 | + require_once dirname(__FILE__) . '/includes/compat/class-wc-stripe-sepa-subs-compat.php'; |
|
133 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-order-handler.php'; |
|
134 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-payment-tokens.php'; |
|
135 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-customer.php'; |
|
136 | + require_once dirname(__FILE__) . '/includes/class-wc-stripe-intent-controller.php'; |
|
137 | + |
|
138 | + if (is_admin()) { |
|
139 | + require_once dirname(__FILE__) . '/includes/admin/class-wc-stripe-admin-notices.php'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | // REMOVE IN THE FUTURE. |
143 | - require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
143 | + require_once dirname(__FILE__) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; |
|
144 | 144 | |
145 | - add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateways' ) ); |
|
146 | - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) ); |
|
145 | + add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); |
|
146 | + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_action_links')); |
|
147 | 147 | |
148 | 148 | // Modify emails emails. |
149 | - add_filter( 'woocommerce_email_classes', array( $this, 'add_emails' ), 20 ); |
|
149 | + add_filter('woocommerce_email_classes', array($this, 'add_emails'), 20); |
|
150 | 150 | |
151 | - if ( version_compare( WC_VERSION, '3.4', '<' ) ) { |
|
152 | - add_filter( 'woocommerce_get_sections_checkout', array( $this, 'filter_gateway_order_admin' ) ); |
|
151 | + if (version_compare(WC_VERSION, '3.4', '<')) { |
|
152 | + add_filter('woocommerce_get_sections_checkout', array($this, 'filter_gateway_order_admin')); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @version 4.0.0 |
161 | 161 | */ |
162 | 162 | public function update_plugin_version() { |
163 | - delete_option( 'wc_stripe_version' ); |
|
164 | - update_option( 'wc_stripe_version', WC_STRIPE_VERSION ); |
|
163 | + delete_option('wc_stripe_version'); |
|
164 | + update_option('wc_stripe_version', WC_STRIPE_VERSION); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -171,15 +171,15 @@ discard block |
||
171 | 171 | * @version 3.1.0 |
172 | 172 | */ |
173 | 173 | public function install() { |
174 | - if ( ! is_plugin_active( plugin_basename( __FILE__ ) ) ) { |
|
174 | + if ( ! is_plugin_active(plugin_basename(__FILE__))) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 | |
178 | - if ( ! defined( 'IFRAME_REQUEST' ) && ( WC_STRIPE_VERSION !== get_option( 'wc_stripe_version' ) ) ) { |
|
179 | - do_action( 'woocommerce_stripe_updated' ); |
|
178 | + if ( ! defined('IFRAME_REQUEST') && (WC_STRIPE_VERSION !== get_option('wc_stripe_version'))) { |
|
179 | + do_action('woocommerce_stripe_updated'); |
|
180 | 180 | |
181 | - if ( ! defined( 'WC_STRIPE_INSTALLING' ) ) { |
|
182 | - define( 'WC_STRIPE_INSTALLING', true ); |
|
181 | + if ( ! defined('WC_STRIPE_INSTALLING')) { |
|
182 | + define('WC_STRIPE_INSTALLING', true); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | $this->update_plugin_version(); |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * @since 1.0.0 |
193 | 193 | * @version 4.0.0 |
194 | 194 | */ |
195 | - public function plugin_action_links( $links ) { |
|
195 | + public function plugin_action_links($links) { |
|
196 | 196 | $plugin_links = array( |
197 | - '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__( 'Settings', 'woocommerce-gateway-stripe' ) . '</a>', |
|
198 | - '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__( 'Docs', 'woocommerce-gateway-stripe' ) . '</a>', |
|
199 | - '<a href="https://woocommerce.com/my-account/create-a-ticket?broken=primary&select=18627">' . esc_html__( 'Support', 'woocommerce-gateway-stripe' ) . '</a>', |
|
197 | + '<a href="admin.php?page=wc-settings&tab=checkout§ion=stripe">' . esc_html__('Settings', 'woocommerce-gateway-stripe') . '</a>', |
|
198 | + '<a href="https://docs.woocommerce.com/document/stripe/">' . esc_html__('Docs', 'woocommerce-gateway-stripe') . '</a>', |
|
199 | + '<a href="https://woocommerce.com/my-account/create-a-ticket?broken=primary&select=18627">' . esc_html__('Support', 'woocommerce-gateway-stripe') . '</a>', |
|
200 | 200 | ); |
201 | - return array_merge( $plugin_links, $links ); |
|
201 | + return array_merge($plugin_links, $links); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @since 1.0.0 |
208 | 208 | * @version 4.0.0 |
209 | 209 | */ |
210 | - public function add_gateways( $methods ) { |
|
211 | - if ( class_exists( 'WC_Subscriptions_Order' ) && function_exists( 'wcs_create_renewal_order' ) ) { |
|
210 | + public function add_gateways($methods) { |
|
211 | + if (class_exists('WC_Subscriptions_Order') && function_exists('wcs_create_renewal_order')) { |
|
212 | 212 | $methods[] = 'WC_Stripe_Subs_Compat'; |
213 | 213 | $methods[] = 'WC_Stripe_Sepa_Subs_Compat'; |
214 | 214 | } else { |
@@ -234,28 +234,28 @@ discard block |
||
234 | 234 | * @since 4.0.0 |
235 | 235 | * @version 4.0.0 |
236 | 236 | */ |
237 | - public function filter_gateway_order_admin( $sections ) { |
|
238 | - unset( $sections['stripe'] ); |
|
239 | - unset( $sections['stripe_bancontact'] ); |
|
240 | - unset( $sections['stripe_sofort'] ); |
|
241 | - unset( $sections['stripe_giropay'] ); |
|
242 | - unset( $sections['stripe_eps'] ); |
|
243 | - unset( $sections['stripe_ideal'] ); |
|
244 | - unset( $sections['stripe_p24'] ); |
|
245 | - unset( $sections['stripe_alipay'] ); |
|
246 | - unset( $sections['stripe_sepa'] ); |
|
247 | - unset( $sections['stripe_multibanco'] ); |
|
237 | + public function filter_gateway_order_admin($sections) { |
|
238 | + unset($sections['stripe']); |
|
239 | + unset($sections['stripe_bancontact']); |
|
240 | + unset($sections['stripe_sofort']); |
|
241 | + unset($sections['stripe_giropay']); |
|
242 | + unset($sections['stripe_eps']); |
|
243 | + unset($sections['stripe_ideal']); |
|
244 | + unset($sections['stripe_p24']); |
|
245 | + unset($sections['stripe_alipay']); |
|
246 | + unset($sections['stripe_sepa']); |
|
247 | + unset($sections['stripe_multibanco']); |
|
248 | 248 | |
249 | 249 | $sections['stripe'] = 'Stripe'; |
250 | - $sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' ); |
|
251 | - $sections['stripe_sofort'] = __( 'Stripe SOFORT', 'woocommerce-gateway-stripe' ); |
|
252 | - $sections['stripe_giropay'] = __( 'Stripe Giropay', 'woocommerce-gateway-stripe' ); |
|
253 | - $sections['stripe_eps'] = __( 'Stripe EPS', 'woocommerce-gateway-stripe' ); |
|
254 | - $sections['stripe_ideal'] = __( 'Stripe iDeal', 'woocommerce-gateway-stripe' ); |
|
255 | - $sections['stripe_p24'] = __( 'Stripe P24', 'woocommerce-gateway-stripe' ); |
|
256 | - $sections['stripe_alipay'] = __( 'Stripe Alipay', 'woocommerce-gateway-stripe' ); |
|
257 | - $sections['stripe_sepa'] = __( 'Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe' ); |
|
258 | - $sections['stripe_multibanco'] = __( 'Stripe Multibanco', 'woocommerce-gateway-stripe' ); |
|
250 | + $sections['stripe_bancontact'] = __('Stripe Bancontact', 'woocommerce-gateway-stripe'); |
|
251 | + $sections['stripe_sofort'] = __('Stripe SOFORT', 'woocommerce-gateway-stripe'); |
|
252 | + $sections['stripe_giropay'] = __('Stripe Giropay', 'woocommerce-gateway-stripe'); |
|
253 | + $sections['stripe_eps'] = __('Stripe EPS', 'woocommerce-gateway-stripe'); |
|
254 | + $sections['stripe_ideal'] = __('Stripe iDeal', 'woocommerce-gateway-stripe'); |
|
255 | + $sections['stripe_p24'] = __('Stripe P24', 'woocommerce-gateway-stripe'); |
|
256 | + $sections['stripe_alipay'] = __('Stripe Alipay', 'woocommerce-gateway-stripe'); |
|
257 | + $sections['stripe_sepa'] = __('Stripe SEPA Direct Debit', 'woocommerce-gateway-stripe'); |
|
258 | + $sections['stripe_multibanco'] = __('Stripe Multibanco', 'woocommerce-gateway-stripe'); |
|
259 | 259 | |
260 | 260 | return $sections; |
261 | 261 | } |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | * @param WC_Email[] $email_classes All existing emails. |
267 | 267 | * @return WC_Email[] |
268 | 268 | */ |
269 | - public function add_emails( $email_classes ) { |
|
269 | + public function add_emails($email_classes) { |
|
270 | 270 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-authentication.php'; |
271 | 271 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-renewal-authentication.php'; |
272 | 272 | require_once WC_STRIPE_PLUGIN_PATH . '/includes/compat/class-wc-stripe-email-failed-preorder-authentication.php'; |
273 | 273 | |
274 | 274 | // Add all emails, generated by the gateway. |
275 | - $email_classes['WC_Stripe_Email_Failed_Renewal_Authentication'] = new WC_Stripe_Email_Failed_Renewal_Authentication( $email_classes ); |
|
276 | - $email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication( $email_classes ); |
|
275 | + $email_classes['WC_Stripe_Email_Failed_Renewal_Authentication'] = new WC_Stripe_Email_Failed_Renewal_Authentication($email_classes); |
|
276 | + $email_classes['WC_Stripe_Email_Failed_Preorder_Authentication'] = new WC_Stripe_Email_Failed_Preorder_Authentication($email_classes); |
|
277 | 277 | |
278 | 278 | return $email_classes; |
279 | 279 | } |