Curl problem and a proposed solution
-
I have been having problems with curl requests from my server. The page would just hang on “validating” because admin-ajax.php would not give a response.
The issue was with curl configuration. It turned out that curl needed to be told how to resolve the ip by adding a line “curl_setopt( $curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);” to your alg-wc-eu-vat-functions-validation.php in function alg_wc_eu_vat_validate_vat_no_soap.
... function alg_wc_eu_vat_validate_vat_no_soap( $country_code, $vat_number, $billing_company, $method ) { $country_code = strtoupper( $country_code ); $api_url = "https://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=" . $country_code . "&vat=" . $vat_number; $api_url = "https://ec.europa.eu/taxation_customs/vies/rest-api/ms/" . $country_code . "/vat/" . $vat_number; switch ( $method ) { case 'file_get_contents': if ( ini_get( 'allow_url_fopen' ) ) { $response = file_get_contents( $api_url ); } else { alg_wc_eu_vat_maybe_log( $country_code, $vat_number, $billing_company, $method, sprintf( __( 'Error: %s is disabled', 'eu-vat-for-woocommerce' ), 'allow_url_fopen' ) ); return null; } break; default: // 'curl' if ( function_exists( 'curl_version' ) ) { $curl = curl_init( $api_url ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //proposed change ...
Would you consider this change in a future version of the plugin so that I don’t need to change it with every update?
Thanks for the great work you are doing!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Curl problem and a proposed solution’ is closed to new replies.