Maybe to test what is going on, you could change this line in the snippet recaptchav2
to $modx->log(modX::LOG_LEVEL_ERROR, print_r($resp, true)); (or change the log_level in the system settings) to see the return of the verification in the error log.
You could also log the value of “g-recaptcha-response” to check that it is not empty.