diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php index 355ef3f3b..1bc41c257 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php @@ -272,7 +272,7 @@ class PayUponInvoice { } $birth_date = filter_input( INPUT_POST, 'billing_birth_date', FILTER_SANITIZE_STRING ); - if ( ! $this->pui_helper->validate_birth_date( $birth_date ) ) { + if ( $birth_date && ! $this->pui_helper->validate_birth_date( $birth_date ) ) { $errors->add( 'validation', __( 'Invalid birth date.', 'woocommerce-paypal-payments' ) ); } }, diff --git a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php index cd7c6c491..ce2dc1b8c 100644 --- a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php +++ b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceHelper.php @@ -33,7 +33,8 @@ class PayUponInvoiceHelper { return false; } - if ( time() < strtotime( '+18 years', strtotime( $date ) ) ) { + $date_time = strtotime( $date ); + if ( $date_time && time() < strtotime( '+18 years', $date_time ) ) { return false; } diff --git a/tests/PHPUnit/WcGateway/Helper/PayUponInvoiceHelperTest.php b/tests/PHPUnit/WcGateway/Helper/PayUponInvoiceHelperTest.php index 5a073c95a..3a1d9bdc0 100644 --- a/tests/PHPUnit/WcGateway/Helper/PayUponInvoiceHelperTest.php +++ b/tests/PHPUnit/WcGateway/Helper/PayUponInvoiceHelperTest.php @@ -23,7 +23,7 @@ class PayUponInvoiceHelperTest extends TestCase ['', false], [(new DateTime())->format($format), false], [(new DateTime('-17 years'))->format($format), false], - ['31-02-1942', false], + ['1942-02-31', false], ['01-01-1942', false], ['1942-01-01', true], ];