@@ -31,10 +31,12 @@ public function __construct() {
31
31
* @return void
32
32
*/
33
33
public function add_notice_monei_order_failed () {
34
+ //phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
34
35
if ( ! isset ( $ _GET ['status ' ] ) ) {
35
36
return ;
36
37
}
37
- $ status = wc_clean ( $ _GET ['status ' ] );
38
+ //phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
39
+ $ status = wc_clean ( wp_unslash ( $ _GET ['status ' ] ) );
38
40
if ( $ status === 'FAILED ' ) {
39
41
wc_add_notice ( __ ( 'The payment failed. Please try again ' , 'monei ' ), 'error ' );
40
42
}
@@ -49,19 +51,24 @@ public function add_notice_monei_order_failed() {
49
51
* @return void
50
52
*/
51
53
public function add_notice_monei_order_cancelled ( $ order_id ) {
52
- if ( isset ( $ _GET ['status ' ] ) && isset ( $ _GET ['message ' ] ) && 'FAILED ' === sanitize_text_field ( $ _GET ['status ' ] ) ) {
53
- $ order_id = absint ( $ _GET ['order_id ' ] );
54
- $ order = wc_get_order ( $ order_id );
54
+ // phpcs:disable WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
55
+ if ( isset ( $ _GET ['status ' ] ) && isset ( $ _GET ['message ' ] ) && 'FAILED ' === wc_clean ( wp_unslash ( $ _GET ['status ' ] ) ) ) {
56
+ $ order_id = isset ( $ _GET ['order_id ' ] ) ? absint ( $ _GET ['order_id ' ] ) : false ;
57
+ $ order = $ order_id ? wc_get_order ( $ order_id ) : false ;
58
+ if ( ! $ order ) {
59
+ return ;
60
+ }
55
61
56
- $ order ->add_order_note ( __ ( 'MONEI Status: ' , 'monei ' ) . esc_html ( sanitize_text_field ( $ _GET ['status ' ] ) ) );
57
- $ order ->add_order_note ( __ ( 'MONEI message: ' , 'monei ' ) . esc_html ( sanitize_text_field ( $ _GET ['message ' ] ) ) );
62
+ $ order ->add_order_note ( __ ( 'MONEI Status: ' , 'monei ' ) . esc_html ( wc_clean ( wp_unslash ( $ _GET ['status ' ] ) ) ) );
63
+ $ order ->add_order_note ( __ ( 'MONEI message: ' , 'monei ' ) . esc_html ( wc_clean ( wp_unslash ( $ _GET ['message ' ] ) ) ) );
58
64
59
- wc_add_notice ( esc_html ( sanitize_text_field ( $ _GET ['message ' ] ) ), 'error ' );
65
+ wc_add_notice ( esc_html ( wc_clean ( wp_unslash ( $ _GET ['message ' ] ) ) ), 'error ' );
60
66
61
67
WC_Monei_Logger::log ( __ ( 'Order Cancelled: ' , 'monei ' ) . $ order_id );
62
- WC_Monei_Logger::log ( __ ( 'MONEI Status: ' , 'monei ' ) . esc_html ( sanitize_text_field ( $ _GET ['status ' ] ) ) );
63
- WC_Monei_Logger::log ( __ ( 'MONEI message: ' , 'monei ' ) . esc_html ( sanitize_text_field ( $ _GET ['message ' ] ) ) );
68
+ WC_Monei_Logger::log ( __ ( 'MONEI Status: ' , 'monei ' ) . esc_html ( wc_clean ( wp_unslash ( $ _GET ['status ' ] ) ) ) );
69
+ WC_Monei_Logger::log ( __ ( 'MONEI message: ' , 'monei ' ) . esc_html ( wc_clean ( wp_unslash ( $ _GET ['message ' ] ) ) ) );
64
70
}
71
+ // phpcs:enable
65
72
}
66
73
67
74
/**
@@ -80,7 +87,7 @@ public function save_payment_token() {
80
87
if ( ! is_add_payment_method_page () && ! is_order_received_page () ) {
81
88
return ;
82
89
}
83
-
90
+ //phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
84
91
if ( ! isset ( $ _GET ['id ' ] ) ) {
85
92
return ;
86
93
}
@@ -89,7 +96,8 @@ public function save_payment_token() {
89
96
* In the redirect back (from add payment method), the payment could have been failed, the only way to check is the url $_GET['status']
90
97
* We should remove the "Payment method successfully added." notice and add a 'Unable to add payment method to your account.' manually.
91
98
*/
92
- if ( is_add_payment_method_page () && ( ! isset ( $ _GET ['status ' ] ) || 'SUCCEEDED ' !== sanitize_text_field ( $ _GET ['status ' ] ) ) ) {
99
+ //phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
100
+ if ( is_add_payment_method_page () && ( ! isset ( $ _GET ['status ' ] ) || 'SUCCEEDED ' !== wc_clean ( wp_unslash ( $ _GET ['status ' ] ) ) ) ) {
93
101
wc_clear_notices ();
94
102
wc_add_notice ( __ ( 'Unable to add payment method to your account. ' , 'woocommerce ' ), 'error ' );
95
103
$ error_message = filter_input ( INPUT_GET , 'message ' , FILTER_CALLBACK , array ( 'options ' => 'sanitize_text_field ' ) );
@@ -132,7 +140,7 @@ public function save_payment_token() {
132
140
WC_Monei_Logger::log ( 'saving tokent into DB ' , 'debug ' );
133
141
WC_Monei_Logger::log ( $ payment_method , 'debug ' );
134
142
135
- $ expiration = new DateTime ( date ( 'm/d/Y ' , $ payment_method ->getCard ()->getExpiration () ) );
143
+ $ expiration = new DateTime ( gmdate ( 'm/d/Y ' , $ payment_method ->getCard ()->getExpiration () ) );
136
144
137
145
$ token = new WC_Payment_Token_CC ();
138
146
$ token ->set_token ( $ payment_token );
0 commit comments