Exemplo n.º 1
0
 public function getCodes($code_type = NULL, array $tax_request_options = NULL)
 {
     if ($code_type !== NULL) {
         $this->setCodeType($code_type);
     }
     if ($tax_request_options !== NULL && is_array($tax_request_options)) {
         $this->setTaxRequestOptions($tax_request_options);
     }
     $data = array('CodeType' => $this->code_type === NULL ? '' : $this->code_type, 'Options' => array());
     if ($this->tax_request_options) {
         foreach ($this->tax_request_options as $tax_request_option) {
             $data['Options'][] = array('TaxRequestOption' => array('Key' => $tax_request_option->getKey(), 'Value' => $tax_request_option->getValue()));
         }
     }
     $communicator = new Communicator($this->taxify);
     $return = $communicator->call(self::CALL_GET_CODES, $data);
     $this->codes = array();
     $this->setCodeType($return['CodeType']);
     foreach ($return['Codes'] as $code) {
         $c = new Code($code);
         $this->codes[] = $c;
     }
     return $this->codes;
 }
Exemplo n.º 2
0
 public function verifyAddress()
 {
     if ($this->taxify === NULL) {
         throw new Exception(self::ERROR_TAXIFY_OBJ_NOT_PRESENT);
     }
     $this->is_validated = FALSE;
     $this->validation_status = NULL;
     $this->original_address = clone $this;
     $this->original_address->clearObjectProperties();
     $communicator = new Communicator($this->taxify);
     $return = $communicator->call(self::CALL_VERIFY_ADDRESS, $this->toArray());
     $this->validation_status = $return['Address']['ValidationStatus'];
     $this->is_validated = $this->validation_status == self::VALIDATION_SUCCESS;
     $this->setFirstName($return['Address']['FirstName'])->setLastName($return['Address']['LastName'])->setCompany($return['Address']['Company'])->setStreet1($return['Address']['Street1'])->setStreet2($return['Address']['Street2'])->setCity($return['Address']['City'])->setCounty($return['Address']['County'])->setRegion($return['Address']['Region'])->setPostalCode($return['Address']['PostalCode'])->setCountry($return['Address']['Country'])->setEmail($return['Address']['Email'])->setPhone($return['Address']['Phone'])->setResidentialOrBusinessType($return['Address']['ResidentialOrBusinessType']);
     /** TODO: Check for AddressSuggestions (need to find an address where this is populated so I can test it first) */
 }
Exemplo n.º 3
0
 public function commitTax()
 {
     if (empty($this->document_key)) {
         throw new Exception(self::ERROR_NO_DOCUMENT_KEY);
     }
     $data = array('DocumentKey' => Taxify::toString($this->document_key), 'CommitedDocumentKey' => Taxify::toString($this->committed_document_key));
     $communicator = new Communicator($this->taxify);
     $return = $communicator->call(self::CALL_COMMIT_TAX, $data);
     $tax_response = new TaxResponse();
     $tax_response->setResponseStatus(1);
     $tax_response->setExtendedProperties($return['ExtendedProperties']);
     return $tax_response;
 }