diff --git a/htdocs/societe/checkvat/checkVatGr.php b/htdocs/societe/checkvat/checkVatGr.php new file mode 100644 index 00000000000..9018081cf68 --- /dev/null +++ b/htdocs/societe/checkvat/checkVatGr.php @@ -0,0 +1,54 @@ +. + */ + +/** + * \file htdocs/societe/checkvat/checkVatGr.php + * \ingroup societe + * \brief Request VAT details from the Greek Ministry of Finance GSIS SOAP web service + */ + +$username = (isset($_REQUEST['u']) ? $_REQUEST['u'] : ''); // Get username from request +$password = (isset($_REQUEST['p']) ? $_REQUEST['p'] : ''); // Get password from request +$myafm = (isset($_REQUEST['myafm']) ? $_REQUEST['myafm'] : ''); // Get Vat from request +$afm = (isset($_REQUEST['afm']) ? $_REQUEST['afm'] : ''); // Get client Vat from request + +// Make call to check VAT for Greek client +$result = checkVATGR($username, $password, $myafm, $afm); + +echo json_encode($result); // Encode the result as JSON and output + +// Function to check VAT +function checkVATGR($username, $password, $AFMcalledby = '', $AFMcalledfor) +{ + $client = new SoapClient("https://www1.gsis.gr/webtax2/wsgsis/RgWsPublic/RgWsPublicPort?WSDL", array('trace' => true)); + $authHeader = new stdClass(); + $authHeader->UsernameToken = new stdClass(); + $authHeader->UsernameToken->Username = "$username"; + $authHeader->UsernameToken->Password = "$password"; + $Headers[] = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader, true); + $client->__setSoapHeaders($Headers); + $result = $client->rgWsPublicAfmMethod( + array( + 'afmCalledBy' => "$AFMcalledby", + 'afmCalledFor' => "$AFMcalledfor", + ) + ); + + return $result; +}