Skip to content

Commit

Permalink
Add register inscription proof web service
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanalemunioz committed Jan 21, 2021
1 parent 762df57 commit c6a5075
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Afip.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Afip {
'ElectronicBilling',
'RegisterScopeFour',
'RegisterScopeFive',
'RegisterInscriptionProof',
'RegisterScopeTen',
'RegisterScopeThirteen'
);
Expand Down Expand Up @@ -224,7 +225,8 @@ private function CreateServiceTA($service)
'soap_version' => SOAP_1_2,
'location' => $this->WSAA_URL,
'trace' => 1,
'exceptions' => 0
'exceptions' => 0,
'stream_context' => stream_context_create(['ssl'=> ['verify_peer'=> false,'verify_peer_name'=> false]])
));
$results=$client->loginCms(array('in0'=>$CMS));
if (is_soap_fault($results))
Expand Down Expand Up @@ -373,7 +375,8 @@ public function ExecuteRequest($operation, $params = array())
'soap_version' => $this->soap_version,
'location' => $this->URL,
'trace' => 1,
'exceptions' => 0
'exceptions' => 0,
'stream_context' => stream_context_create(['ssl'=> ['verify_peer'=> false,'verify_peer_name'=> false]])
));
}

Expand Down
109 changes: 109 additions & 0 deletions src/Class/RegisterInscriptionProof.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php
/**
* SDK for AFIP Register Scope Five (ws_sr_padron_a5)
*
* @link http://www.afip.gob.ar/ws/ws_sr_padron_a5/manual_ws_sr_padron_a5_v1.0.pdf WS Specification
*
* @author Afip SDK
* @package Afip
* @version 1.0
**/

class RegisterInscriptionProof extends AfipWebService {

var $soap_version = SOAP_1_1;
var $WSDL = 'ws_sr_padron_a5-production.wsdl';
var $URL = 'https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA5';
var $WSDL_TEST = 'ws_sr_padron_a5.wsdl';
var $URL_TEST = 'https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA5';

/**
* Asks to web service for servers status {@see WS
* Specification item 3.1}
*
* @since 1.0
*
* @return object { appserver => Web Service status,
* dbserver => Database status, authserver => Autentication
* server status}
**/
public function GetServerStatus()
{
return $this->ExecuteRequest('dummy');
}

/**
* Asks to web service for taxpayer details {@see WS
* Specification item 3.2}
*
* @since 1.0
*
* @throws Exception if exists an error in response
*
* @return object|null if taxpayer does not exists, return null,
* if it exists, returns full response {@see
* WS Specification item 3.2.2}
**/
public function GetTaxpayerDetails($identifier)
{
$ta = $this->afip->GetServiceTA('ws_sr_padron_a5');

$params = array(
'token' => $ta->token,
'sign' => $ta->sign,
'cuitRepresentada' => $this->afip->CUIT,
'idPersona' => $identifier
);

try {
return $this->ExecuteRequest('getPersona_v2', $params);
} catch (Exception $e) {
if (strpos($e->getMessage(), 'No existe') !== FALSE)
return NULL;
else
throw $e;
}
}

/**
* Asks to web service for taxpayers details
*
* @throws Exception if exists an error in response
*
* @return [object] returns web service full response
**/
public function GetTaxpayersDetails($identifiers)
{
$ta = $this->afip->GetServiceTA('ws_sr_padron_a5');

$params = array(
'token' => $ta->token,
'sign' => $ta->sign,
'cuitRepresentada' => $this->afip->CUIT,
'idPersona' => $identifiers
);

return $this->ExecuteRequest('getPersonaList_v2', $params)->persona;
}

/**
* Sends request to AFIP servers
*
* @since 1.0
*
* @param string $operation SOAP operation to do
* @param array $params Parameters to send
*
* @return mixed Operation results
**/
public function ExecuteRequest($operation, $params = array())
{
$results = parent::ExecuteRequest($operation, $params);

return $results->{
$operation === 'getPersona_v2' ? 'personaReturn' :
($operation === 'getPersonaList_v2' ? 'personaListReturn': 'return')
};
}
}

0 comments on commit c6a5075

Please sign in to comment.