diff --git a/src/Afip.php b/src/Afip.php index 20cb9b6..63f1d7c 100644 --- a/src/Afip.php +++ b/src/Afip.php @@ -79,6 +79,7 @@ class Afip { 'ElectronicBilling', 'RegisterScopeFour', 'RegisterScopeFive', + 'RegisterInscriptionProof', 'RegisterScopeTen', 'RegisterScopeThirteen' ); @@ -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)) @@ -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]]) )); } diff --git a/src/Class/RegisterInscriptionProof.php b/src/Class/RegisterInscriptionProof.php new file mode 100644 index 0000000..2e0f664 --- /dev/null +++ b/src/Class/RegisterInscriptionProof.php @@ -0,0 +1,109 @@ + 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') + }; + } +} +