Request VAT details from the Greek Ministry of Finance GSIS SOAP web service

This commit is contained in:
sonikf
2023-09-12 01:05:49 +03:00
committed by GitHub
parent ad323a6de8
commit b77e20b6bf

View File

@@ -0,0 +1,54 @@
<?php
/* Copyright (C) 2016 Spiros Ioannou
* Copyright (C) 2017 Marios Kaintatzis
* Copyright (C) 2023 Nick Fragoulis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \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;
}