src/SimpleAddressValidation.php
private function createRequest()
    {
        $xml = new DOMDocument();
        $xml->formatOutput = true;

        $avRequest = $xml->appendChild($xml->createElement('AddressValidationRequest'));
        $avRequest->setAttribute('xml:lang', 'en-US');

        $request = $avRequest->appendChild($xml->createElement('Request'));

        $node = $xml->importNode($this->createTransactionNode(), true);
        $request->appendChild($node);

        $request->appendChild($xml->createElement('RequestAction', 'AV'));

        if (null !== $this->address) {
            $addressNode = $avRequest->appendChild($xml->createElement('Address'));

            if ($this->address->getStateProvinceCode()) {
                $addressNode->appendChild($xml->createElement('StateProvinceCode', $this->address->getStateProvinceCode()));
            }
            if ($this->address->getCity()) {
                $addressNode->appendChild($xml->createElement('City', $this->address->getCity()));
            }
            if ($this->address->getCountryCode()) {
                $addressNode->appendChild($xml->createElement('CountryCode', $this->address->getCountryCode()));
            }
            if ($this->address->getPostalCode()) {
                $addressNode->appendChild($xml->createElement('PostalCode', $this->address->getPostalCode()));
            }
        }

        return $xml->saveXML();
    }
private function createRequest()
    {
        $xml = new DOMDocument();
        $xml->formatOutput = true;

        $avRequest = $xml->appendChild($xml->createElement('AddressValidationRequest'));
        $avRequest->setAttribute('xml:lang', 'en-US');

        $request = $avRequest->appendChild($xml->createElement('Request'));

        $node = $xml->importNode($this->createTransactionNode(), true);
        $request->appendChild($node);

        $request->appendChild($xml->createElement('RequestAction', 'AV'));

        if (null !== $this->address) {
            $addressNode = $avRequest->appendChild($xml->createElement('Address'));

            if ($this->address->getStateProvinceCode()) {
                $addressNode->appendChild($xml->createElement('StateProvinceCode', $this->address->getStateProvinceCode()));
            }
            if ($this->address->getCity()) {
                $addressNode->appendChild($xml->createElement('City', $this->address->getCity()));
            }
            if ($this->address->getCountryCode()) {
                $addressNode->appendChild($xml->createElement('CountryCode', $this->address->getCountryCode()));
            }
            if ($this->address->getPostalCode()) {
                $addressNode->appendChild($xml->createElement('PostalCode', $this->address->getPostalCode()));
            }
        }

        return $xml->saveXML();
    }
private function createRequest ( ) { $ xml = new DOMDocument ( ) ; $ xml -> formatOutput = true ; $ avRequest = $ xml -> appendChild ( $ xml -> createElement ( 'AddressValidationRequest' ) ) ; $ avRequest -> setAttribute ( 'xml:lang' , 'en-US' ) ; $ request = $ avRequest -> appendChild ( $ xml -> createElement ( 'Request' ) ) ; $ node = $ xml -> importNode ( $ this -> createTransactionNode ( ) , true ) ; $ request -> appendChild ( $ node ) ; $ request -> appendChild ( $ xml -> createElement ( 'RequestAction' , 'AV' ) ) ; if ( null !== $ this -> address ) { $ addressNode = $ avRequest -> appendChild ( $ xml -> createElement ( 'Address' ) ) ; if ( $ this -> address -> getStateProvinceCode ( ) ) { $ addressNode -> appendChild ( $ xml -> createElement ( 'StateProvinceCode' , $ this -> address -> getStateProvinceCode ( ) ) ) ; } if ( $ this -> address -> getCity ( ) ) { $ addressNode -> appendChild ( $ xml -> createElement ( 'City' , $ this -> address -> getCity ( ) ) ) ; } if ( $ this -> address -> getCountryCode ( ) ) { $ addressNode -> appendChild ( $ xml -> createElement ( 'CountryCode' , $ this -> address -> getCountryCode ( ) ) ) ; } if ( $ this -> address -> getPostalCode ( ) ) { $ addressNode -> appendChild ( $ xml -> createElement ( 'PostalCode' , $ this -> address -> getPostalCode ( ) ) ) ; } } return $ xml -> saveXML ( ) ; }
Create the AV request.

@return string
Create the AV request .