Example #1
0
 public function ValidateAddressCdyne()
 {
     $this->blnAddressValidFlag = false;
     $this->blnSecondaryValidFlag = false;
     $objClient = new SoapClient('http://pav3.cdyne.com/PavService.svc?wsdl');
     $strRequest = array('FirmOrRecipient' => '', 'PrimaryAddressLine' => $this->strPrimaryAddressLine, 'SecondaryAddressLine' => $this->strSecondaryAddressLine, 'Urbanization' => '', 'CityName' => $this->strCity, 'State' => $this->strState, 'ZipCode' => $this->strZipCode, 'LicenseKey' => 'd0ca63f0-ef2f-433b-acb9-595302dd235d');
     $objResult = $objClient->VerifyAddress($strRequest);
     $objResult = $objResult->VerifyAddressResult;
     if ($objResult->ReturnCode == 100 || $objResult->ReturnCode == 101 || $objResult->ReturnCode == 102) {
         $strAddress1 = $objResult->PrimaryAddressLine;
         $strAddress2 = $objResult->SecondaryAddressLine;
         if (!$strAddress2) {
             foreach (array('APT', 'BLDG', 'DEPT', 'FL', 'RM', 'STE', 'UNIT') as $strUnitDesignator) {
                 $intPosition = strpos($strAddress1, ' ' . $strUnitDesignator . ' ');
                 if ($intPosition !== false) {
                     $strAddress2 = trim(substr($strAddress1, $intPosition));
                     $strAddress1 = trim(substr($strAddress1, 0, $intPosition));
                 }
             }
         }
         $this->strPrimaryAddressLine = $strAddress1;
         $this->strSecondaryAddressLine = $strAddress2;
         $this->strCity = $objResult->CityName;
         $this->strState = $objResult->StateAbbreviation;
         $this->strZipCode = $objResult->ZipCode;
         $this->blnAddressValidFlag = true;
         $this->blnSecondaryValidFlag = $objResult->ReturnCode == 100;
     } else {
         $this->blnAddressValidFlag = false;
         $this->blnSecondaryValidFlag = false;
     }
 }