diff --git a/modules/ppcp-vaulting/src/CustomerApprovalListener.php b/modules/ppcp-vaulting/src/CustomerApprovalListener.php index 009fb451c..19ea6ace7 100644 --- a/modules/ppcp-vaulting/src/CustomerApprovalListener.php +++ b/modules/ppcp-vaulting/src/CustomerApprovalListener.php @@ -55,7 +55,7 @@ class CustomerApprovalListener { public function listen(): void { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $token = wc_clean( wp_unslash( $_GET['approval_token_id'] ?? '' ) ); - if ( ! $token ) { + if ( ! $token || is_array($token) ) { return; } diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php index 63c4eee9b..fe152e0bd 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php @@ -421,12 +421,12 @@ class PayUponInvoice { // phpcs:ignore WordPress.Security.NonceVerification.Missing $birth_date = wc_clean( wp_unslash( $_POST['billing_birth_date'] ?? '' ) ); - if ( ( $birth_date && ! $this->checkout_helper->validate_birth_date( $birth_date ) ) || $birth_date === '' ) { + if ( ( $birth_date && is_string( $birth_date ) && ! $this->checkout_helper->validate_birth_date( $birth_date ) ) || $birth_date === '' ) { $errors->add( 'validation', __( 'Invalid birth date.', 'woocommerce-paypal-payments' ) ); } // phpcs:ignore WordPress.Security.NonceVerification.Missing - $national_number = wc_clean( wp_unslash( $_POST['billing_phone'] ?? 0 ) ); + $national_number = wc_clean( wp_unslash( $_POST['billing_phone'] ?? '' ) ); if ( ! $national_number ) { $errors->add( 'validation', __( 'Phone field cannot be empty.', 'woocommerce-paypal-payments' ) ); } @@ -532,7 +532,7 @@ class PayUponInvoice { function( string $post_type ) { if ( $post_type === 'shop_order' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $post_id = wc_clean( wp_unslash( $_GET['post'] ?? 0 ) ); + $post_id = wc_clean( wp_unslash( $_GET['post'] ?? '' ) ); $order = wc_get_order( $post_id ); if ( is_a( $order, WC_Order::class ) && $order->get_payment_method() === PayUponInvoiceGateway::ID ) { $instructions = $order->get_meta( 'ppcp_ratepay_payment_instructions_payment_reference' ); diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PaymentSourceFactory.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PaymentSourceFactory.php index 960a82f87..0388132c5 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PaymentSourceFactory.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PaymentSourceFactory.php @@ -26,7 +26,10 @@ class PaymentSourceFactory { public function from_wc_order( WC_Order $order, string $birth_date ) { $address = $order->get_address(); // phpcs:ignore WordPress.Security.NonceVerification.Missing - $phone = wc_clean( wp_unslash( $_POST['billing_phone'] ?? '' ) ) ?? $address['phone'] ?? ''; + $phone = wc_clean( wp_unslash( $_POST['billing_phone'] ?? '' ) ); + if ( ! $phone ) { + $phone = $address['phone'] ?? ''; + } $phone_country_code = WC()->countries->get_country_calling_code( $address['country'] ); $phone_country_code = is_array( $phone_country_code ) && ! empty( $phone_country_code ) ? $phone_country_code[0] : $phone_country_code; if ( is_string( $phone_country_code ) && '' !== $phone_country_code ) {