Skip to content

Commit f5566cc

Browse files
committed
Fix errors and warnings
1 parent d54055c commit f5566cc

13 files changed

+190
-171
lines changed

includes/abstracts/abstract-wc-monei-payment-gateway-component.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,16 @@ public function create_payload( $order, $allowed_payment_method = null ) {
188188
);
189189

190190
// If customer has selected a saved payment method, we get the token from $_POST and we add it to the payload.
191-
if ( $token_id = $this->get_payment_token_id_if_selected() ) {
191+
$token_id = $this->get_payment_token_id_if_selected();
192+
if ( $token_id ) {
192193
$wc_token = WC_Payment_Tokens::get( $token_id );
193194
$payload['paymentToken'] = $wc_token->get_token();
194195
}
195196

196197
// If user has paid using Apple or Google pay, we add paymentToken.
197198
// This will overwrite previous token, in case one preselected token was checked in checkout, but we should ignore it.
198-
if ( $token_id = $this->get_frontend_generated_monei_apple_google_token() ) {
199+
$token_id = $this->get_frontend_generated_monei_apple_google_token();
200+
if ( $token_id ) {
199201
$payload['paymentToken'] = $token_id;
200202
}
201203

@@ -205,7 +207,7 @@ public function create_payload( $order, $allowed_payment_method = null ) {
205207
}
206208
$componentGateways = array( MONEI_GATEWAY_ID, self::APPLE_GOOGLE_ID );
207209
// If merchant is not using redirect flow (means component CC or apple/google pay), there is a generated frontend token paymentToken and we need to add session ID to the request.
208-
if ( in_array( $this->id, $componentGateways ) && ! $this->redirect_flow && ( $this->get_frontend_generated_monei_token() || $this->get_frontend_generated_monei_apple_google_token() ) ) {
210+
if ( in_array( $this->id, $componentGateways, true ) && ! $this->redirect_flow && ( $this->get_frontend_generated_monei_token() || $this->get_frontend_generated_monei_apple_google_token() ) ) {
209211
$payload['sessionId'] = (string) WC()->session->get_customer_id();
210212
}
211213

@@ -219,7 +221,8 @@ public function create_payload( $order, $allowed_payment_method = null ) {
219221
* @return false|string
220222
*/
221223
public function get_frontend_generated_monei_token() {
222-
return ( isset( $_POST['monei_payment_token'] ) ) ? htmlspecialchars( strip_tags( $_POST['monei_payment_token'] ), ENT_QUOTES, 'UTF-8' ) : false; // WPCS: CSRF ok.
224+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
225+
return ( isset( $_POST['monei_payment_token'] ) ) ? wc_clean( wp_unslash( $_POST['monei_payment_token'] ) ) : false; // WPCS: CSRF ok.
223226
}
224227

225228
/**
@@ -228,7 +231,8 @@ public function get_frontend_generated_monei_token() {
228231
* @return boolean
229232
*/
230233
public function isBlockCheckout() {
231-
return ( isset( $_POST['monei_is_block_checkout'] ) ) ? htmlspecialchars( strip_tags( $_POST['monei_is_block_checkout'] ), ENT_QUOTES, 'UTF-8' ) === 'yes' : false; // WPCS: CSRF ok.
234+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
235+
return ( isset( $_POST['monei_is_block_checkout'] ) ) ? wc_clean( wp_unslash( $_POST['monei_is_block_checkout'] ) ) === 'yes' : false; // WPCS: CSRF ok.
232236
}
233237

234238
/**
@@ -238,7 +242,8 @@ public function isBlockCheckout() {
238242
*/
239243
public function get_frontend_generated_monei_cardholder( $order ) {
240244
$defaultName = $order->get_formatted_billing_full_name();
241-
return ( isset( $_POST['monei_cardholder_name'] ) ) ? htmlspecialchars( strip_tags( $_POST['monei_cardholder_name'] ), ENT_QUOTES, 'UTF-8' ) : $defaultName; // WPCS: CSRF ok.
245+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
246+
return ( isset( $_POST['monei_cardholder_name'] ) ) ? wc_clean( wp_unslash( $_POST['monei_cardholder_name'] ) ) : $defaultName; // WPCS: CSRF ok.
242247
}
243248

244249
/**
@@ -248,6 +253,7 @@ public function get_frontend_generated_monei_cardholder( $order ) {
248253
* @return false|string
249254
*/
250255
protected function get_frontend_generated_monei_apple_google_token() {
251-
return ( isset( $_POST['monei_payment_request_token'] ) ) ? htmlspecialchars( strip_tags( $_POST['monei_payment_request_token'] ), ENT_QUOTES, 'UTF-8' ) : false; // WPCS: CSRF ok.
256+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
257+
return ( isset( $_POST['monei_payment_request_token'] ) ) ? wc_clean( wp_unslash( $_POST['monei_payment_request_token'] ) ) : false; // WPCS: CSRF ok.
252258
}
253259
}

includes/abstracts/abstract-wc-monei-payment-gateway-hosted.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public function process_payment( $order_id, $allowed_payment_method = null ) {
9797
);
9898

9999
// If customer has selected a saved payment method, we get the token from $_POST and we add it to the payload.
100-
if ( $token_id = $this->get_payment_token_id_if_selected() ) {
100+
$token_id = $this->get_payment_token_id_if_selected();
101+
if ( $token_id ) {
101102
$wc_token = WC_Payment_Tokens::get( $token_id );
102103
$payload['paymentToken'] = $wc_token->get_token();
103104
}
@@ -106,8 +107,8 @@ public function process_payment( $order_id, $allowed_payment_method = null ) {
106107
if ( $this->tokenization && $this->get_save_payment_card_checkbox() ) {
107108
$payload['generatePaymentToken'] = true;
108109
}
109-
110-
if ( $token_id = $this->get_frontend_generated_bizum_token() ) {
110+
$token_id = $this->get_frontend_generated_bizum_token();
111+
if ( $token_id ) {
111112
if ( ! $this->isBlockCheckout() ) {
112113
$payload['paymentToken'] = $token_id;
113114
}
@@ -161,6 +162,7 @@ protected function get_frontend_generated_bizum_token() {
161162
if ( $this->id !== 'monei_bizum' ) {
162163
return false;
163164
}
164-
return ( isset( $_POST['monei_payment_request_token'] ) ) ? htmlspecialchars( strip_tags( $_POST['monei_payment_request_token'] ), ENT_QUOTES, 'UTF-8' ) : false; // WPCS: CSRF ok.
165+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
166+
return ( isset( $_POST['monei_payment_request_token'] ) ) ? wc_clean( wp_unslash( $_POST['monei_payment_request_token'] ) ) : false; // WPCS: CSRF ok.
165167
}
166168
}

includes/abstracts/abstract-wc-monei-payment-gateway.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
182182

183183
$this->log( $amount . ' Refund approved.', 'debug' );
184184

185-
$order->add_order_note( __( '<strong>MONEI Refund Approved:</strong> ', 'monei' ) . wc_price( $amount ) . '<br/>Status: ' . $result->getStatus() . ' ' . $result->getStatusMessage() );
185+
$order->add_order_note( __( 'MONEI Refund Approved:', 'monei' ) . wc_price( $amount ) . '<br/>Status: ' . $result->getStatus() . ' ' . $result->getStatusMessage() );
186186

187187
return true;
188188

@@ -214,7 +214,8 @@ public function save_payment_method_checkbox() {
214214
* @return int|false
215215
*/
216216
protected function get_payment_token_id_if_selected() {
217-
return ( isset( $_POST[ 'wc-' . $this->id . '-payment-token' ] ) ) ? filter_var( $_POST[ 'wc-' . $this->id . '-payment-token' ], FILTER_SANITIZE_NUMBER_INT ) : false; // WPCS: CSRF ok.
217+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
218+
return ( isset( $_POST[ 'wc-' . $this->id . '-payment-token' ] ) ) ? filter_var( wp_unslash( $_POST[ 'wc-' . $this->id . '-payment-token' ] ), FILTER_SANITIZE_NUMBER_INT ) : false; // WPCS: CSRF ok.
218219
}
219220

220221
/**
@@ -223,6 +224,7 @@ protected function get_payment_token_id_if_selected() {
223224
* @return bool
224225
*/
225226
protected function get_save_payment_card_checkbox() {
227+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
226228
return ( isset( $_POST[ 'wc-' . $this->id . '-new-payment-method' ] ) );
227229
}
228230

@@ -298,7 +300,8 @@ public function getTestmode() {
298300
* @return boolean
299301
*/
300302
public function isBlockCheckout() {
301-
return ( isset( $_POST['monei_is_block_checkout'] ) ) ? htmlspecialchars( strip_tags( $_POST['monei_is_block_checkout'] ), ENT_QUOTES, 'UTF-8' ) === 'yes' : false; // WPCS: CSRF ok.
303+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
304+
return ( isset( $_POST['monei_is_block_checkout'] ) ) ? wc_clean( wp_unslash( $_POST['monei_is_block_checkout'] ) ) === 'yes' : false; // WPCS: CSRF ok.
302305
}
303306

304307
/**
@@ -307,17 +310,20 @@ public function isBlockCheckout() {
307310
* @return false|string
308311
*/
309312
public function get_frontend_generated_monei_token() {
310-
return ( isset( $_POST['monei_payment_token'] ) ) ? htmlspecialchars( strip_tags( $_POST['monei_payment_token'] ), ENT_QUOTES, 'UTF-8' ) : false; // WPCS: CSRF ok.
313+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
314+
return ( isset( $_POST['monei_payment_token'] ) ) ? wc_clean( wp_unslash( $_POST['monei_payment_token'] ) ) : false; // WPCS: CSRF ok.
311315
}
312316

313317
/**
314318
* @return float|int|string|null
315319
*/
316320
public function determineTheTotalAmountToBePassed() {
317321
$total = null;
322+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
318323
if ( is_wc_endpoint_url( 'order-pay' ) && isset( $_GET['key'] ) ) {
319324
// If on the pay for order page, get the order total
320-
$order_id = wc_get_order_id_by_order_key( sanitize_text_field( $_GET['key'] ) );
325+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
326+
$order_id = wc_get_order_id_by_order_key( wc_clean( wp_unslash( $_GET['key'] ) ) );
321327
if ( $order_id ) {
322328
$order = wc_get_order( $order_id );
323329
$total = $order ? $order->get_total() : 0;

includes/addons/class-wc-monei-addons-redirect-hooks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function subscriptions_save_sequence_id_on_payment_method_change() {
3333
if ( ! is_account_page() ) {
3434
return;
3535
}
36-
36+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
3737
if ( ! isset( $_GET['id'] ) ) {
3838
return;
3939
}
@@ -78,7 +78,7 @@ public function subscriptions_save_sequence_id() {
7878
if ( ! is_order_received_page() ) {
7979
return;
8080
}
81-
81+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
8282
if ( ! isset( $_GET['id'] ) ) {
8383
return;
8484
}

includes/addons/class-wc-monei-apple-pay-verification.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function apple_domain_register() {
3030
if ( ! isset( $_POST['woocommerce_monei_apple_google_pay'] ) ) {
3131
return;
3232
}
33-
34-
if ( ! sanitize_text_field( $_POST['woocommerce_monei_apple_google_pay'] ) ) {
33+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
34+
if ( ! wc_clean( wp_unslash( $_POST['woocommerce_monei_apple_google_pay'] ) ) ) {
3535
return;
3636
}
3737

includes/addons/trait-wc-monei-subscriptions.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ public function create_subscription_payload( WC_Order $order_id, $payment_method
163163
$payload['sequence'] = array(
164164
'type' => 'recurring',
165165
'recurring' => array(
166-
// 'frequency' => $this->get_cart_subscription_interval_in_days() // The minimum number of days between the different recurring payments.
167166
'frequency' => 1, // Testing with 1 to know if we can modify subscription dates.
168167
),
169168
);

includes/class-monei-cc-blocks.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ public function is_active() {
3232
/**
3333
* Removes all saved payment methods when the setting to save cards is disabled.
3434
*
35-
* @param array $list List of payment methods passed from wc_get_customer_saved_methods_list().
35+
* @param array $paymentMethods List of payment methods passed from wc_get_customer_saved_methods_list().
3636
* @param int $customer_id The customer to fetch payment methods for.
3737
* @return array Filtered list of customers payment methods.
3838
*/
39-
public function filter_saved_payment_methods_list( $list, $customer_id ) {
39+
public function filter_saved_payment_methods_list( $paymentMethods, $customer_id ) {
4040

41-
if ( 'no' == $this->get_setting( 'tokenization' ) ) {
41+
if ( 'no' === $this->get_setting( 'tokenization' ) ) {
4242
return array();
4343
}
44-
return $list;
44+
return $paymentMethods;
4545
}
4646

4747

@@ -77,7 +77,7 @@ public function get_payment_method_script_handles() {
7777

7878
public function get_payment_method_data() {
7979

80-
if ( 'no' == $this->get_setting( 'tokenization' ) ) {
80+
if ( 'no' === $this->get_setting( 'tokenization' ) ) {
8181
$supports = $this->get_supported_features();
8282
} else {
8383
$supports = array(

includes/class-wc-monei-ipn.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@ public function __construct( bool $logging = false ) {
2929
* @return void
3030
*/
3131
public function check_ipn_request() {
32-
33-
if ( ( 'POST' !== sanitize_text_field( $_SERVER['REQUEST_METHOD'] ) ) ) {
32+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
33+
if ( isset( $_SERVER['REQUEST_METHOD'] ) && ( 'POST' !== wc_clean( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ) ) {
3434
return;
3535
}
3636

3737
$headers = $this->get_all_headers();
38-
$raw_body = @file_get_contents( 'php://input' );
38+
$raw_body = file_get_contents( 'php://input' );
3939
$this->log_ipn_request( $headers, $raw_body );
4040

4141
try {
42-
$payload = $this->verify_signature_get_payload( $raw_body, sanitize_text_field( $_SERVER['HTTP_MONEI_SIGNATURE'] ) );
42+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
43+
$payload = isset( $_SERVER['HTTP_MONEI_SIGNATURE'] ) && $this->verify_signature_get_payload( $raw_body, wc_clean( wp_unslash( $_SERVER['HTTP_MONEI_SIGNATURE'] ) ) );
4344
$this->logging && WC_Monei_Logger::log( $payload, 'debug' );
4445
$this->handle_valid_ipn( $payload );
4546
do_action( 'woocommerce_monei_handle_valid_ipn', $payload );
@@ -95,7 +96,8 @@ protected function handle_valid_ipn( $payload ) {
9596
if ( 'CANCELED' === $status ) {
9697
// Order cancelled.
9798
$order->add_order_note( __( 'HTTP Notification received - <strong>Payment Cancelled</strong>', 'monei' ) . $status );
98-
$order->add_order_note( sprintf( __( 'Cancelled by MONEI: %s', 'monei' ), $status_message ) );
99+
$message = __( 'Cancelled by MONEI: ', 'monei' ) . $status_message;
100+
$order->add_order_note( $message );
99101
return;
100102
}
101103

@@ -119,7 +121,15 @@ protected function handle_valid_ipn( $payload ) {
119121
* 1 cent exception, for subscriptions when 0 sing ups are done.
120122
*/
121123
if ( ( (int) $amount !== monei_price_format( $order_total ) ) && ( 1 !== $amount ) ) {
122-
$order->update_status( 'on-hold', sprintf( __( 'Validation error: Order vs. Notification amounts do not match (order: %1$s - received: %2&s).', 'monei' ), $amount, monei_price_format( $order_total ) ) );
124+
$order->update_status(
125+
'on-hold',
126+
sprintf(
127+
/* translators: 1: Order amount, 2: Notification amount */
128+
__( 'Validation error: Order vs. Notification amounts do not match (order: %1$s - received: %2$s).', 'monei' ),
129+
$amount,
130+
monei_price_format( $order_total )
131+
)
132+
);
123133
exit;
124134
}
125135

@@ -165,7 +175,7 @@ private function get_all_headers() {
165175
if ( ! function_exists( 'getallheaders' ) ) {
166176
$headers = array();
167177
foreach ( $_SERVER as $name => $value ) {
168-
if ( substr( $name, 0, 5 ) == 'HTTP_' ) {
178+
if ( substr( $name, 0, 5 ) === 'HTTP_' ) {
169179
$headers[ str_replace( ' ', '-', ucwords( strtolower( str_replace( '_', ' ', substr( $name, 5 ) ) ) ) ) ] = $value;
170180
}
171181
}

includes/class-wc-monei-pre-auth.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public function __construct() {
2929
* @param $order_id
3030
*/
3131
public function capture_payment_when_pre_auth( $order_id ) {
32-
$order = wc_get_order( $order_id );
33-
34-
if ( ! $payment_id = $this->is_pre_auth_order( $order ) ) {
32+
$order = wc_get_order( $order_id );
33+
$payment_id = $this->is_pre_auth_order( $order );
34+
if ( ! $payment_id ) {
3535
return;
3636
}
3737

@@ -56,9 +56,9 @@ public function capture_payment_when_pre_auth( $order_id ) {
5656
* @param $order_id
5757
*/
5858
public function cancel_payment_when_pre_auth( $order_id ) {
59-
$order = wc_get_order( $order_id );
60-
61-
if ( ! $payment_id = $this->is_pre_auth_order( $order ) ) {
59+
$order = wc_get_order( $order_id );
60+
$payment_id = $this->is_pre_auth_order( $order );
61+
if ( ! $payment_id ) {
6262
return;
6363
}
6464

includes/class-wc-monei-redirect-hooks.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ public function __construct() {
3131
* @return void
3232
*/
3333
public function add_notice_monei_order_failed() {
34+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
3435
if ( ! isset( $_GET['status'] ) ) {
3536
return;
3637
}
37-
$status = wc_clean( $_GET['status'] );
38+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
39+
$status = wc_clean( wp_unslash( $_GET['status'] ) );
3840
if ( $status === 'FAILED' ) {
3941
wc_add_notice( __( 'The payment failed. Please try again', 'monei' ), 'error' );
4042
}
@@ -49,19 +51,24 @@ public function add_notice_monei_order_failed() {
4951
* @return void
5052
*/
5153
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+
}
5561

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'] ) ) ) );
5864

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' );
6066

6167
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'] ) ) ) );
6470
}
71+
// phpcs:enable
6572
}
6673

6774
/**
@@ -80,7 +87,7 @@ public function save_payment_token() {
8087
if ( ! is_add_payment_method_page() && ! is_order_received_page() ) {
8188
return;
8289
}
83-
90+
//phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
8491
if ( ! isset( $_GET['id'] ) ) {
8592
return;
8693
}
@@ -89,7 +96,8 @@ public function save_payment_token() {
8996
* In the redirect back (from add payment method), the payment could have been failed, the only way to check is the url $_GET['status']
9097
* We should remove the "Payment method successfully added." notice and add a 'Unable to add payment method to your account.' manually.
9198
*/
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'] ) ) ) ) {
93101
wc_clear_notices();
94102
wc_add_notice( __( 'Unable to add payment method to your account.', 'woocommerce' ), 'error' );
95103
$error_message = filter_input( INPUT_GET, 'message', FILTER_CALLBACK, array( 'options' => 'sanitize_text_field' ) );
@@ -132,7 +140,7 @@ public function save_payment_token() {
132140
WC_Monei_Logger::log( 'saving tokent into DB', 'debug' );
133141
WC_Monei_Logger::log( $payment_method, 'debug' );
134142

135-
$expiration = new DateTime( date( 'm/d/Y', $payment_method->getCard()->getExpiration() ) );
143+
$expiration = new DateTime( gmdate( 'm/d/Y', $payment_method->getCard()->getExpiration() ) );
136144

137145
$token = new WC_Payment_Token_CC();
138146
$token->set_token( $payment_token );

0 commit comments

Comments
 (0)