JeremyDunn / php-fedex-api-wrapper

This library provides a fluid interface for constructing requests to the FedEx web service API.
269 stars 184 forks source link

Address Validation Issue #92

Closed code2prog closed 5 years ago

code2prog commented 5 years ago

i have method like this:

public function isValid($streetLine1, $streetLine2, $city, $stateCode, $postalCode, $countryCode)
    {

        $addressValidationRequest = new ComplexType\AddressValidationRequest();
// User Credentials
        $addressValidationRequest->WebAuthenticationDetail->UserCredential->Key = $this->config['key'];
        $addressValidationRequest->WebAuthenticationDetail->UserCredential->Password = $this->config['password'];
// Client Detail
        $addressValidationRequest->ClientDetail->AccountNumber = $this->config['account'];
        $addressValidationRequest->ClientDetail->MeterNumber = $this->config['meter'];
// Version
        $addressValidationRequest->Version->ServiceId = 'aval';
        $addressValidationRequest->Version->Major = 4;
        $addressValidationRequest->Version->Intermediate = 0;
        $addressValidationRequest->Version->Minor = 0;

        $addressValidationRequest->AddressesToValidate = [new ComplexType\AddressToValidate()]; // just validating 1 address in this example.
        $addressValidationRequest->AddressesToValidate[0]->Address->StreetLines = [$streetLine1, $streetLine2];
        $addressValidationRequest->AddressesToValidate[0]->Address->City = $city;
        $addressValidationRequest->AddressesToValidate[0]->Address->StateOrProvinceCode = $stateCode;
        $addressValidationRequest->AddressesToValidate[0]->Address->PostalCode = $postalCode;
        $addressValidationRequest->AddressesToValidate[0]->Address->CountryCode = $countryCode;
        $request = new Request();

        $addressValidationReply = $request->getAddressValidationReply($addressValidationRequest,true);
        var_dump($addressValidationReply);
    }

i get weird error code like: SoapFault : SOAP-ERROR: Encoding: Element 'Major' has fixed value '2' (value '4' is not allowed) the code is basically the same as in the examples. I'm using a test api and package in version 2.6.

Thanks for help

JeremyDunn commented 5 years ago

Hi, if you're using 2.6, please change the Major version to 2. The latest version (3.0) is using version 4 of the Address Validation Service

https://github.com/JeremyDunn/php-fedex-api-wrapper/blob/master/CHANGELOG.md