Getting the following error logs: [18-Oct-2017 22:48:33 UTC] PHP Fatal error: SOAP-ERROR: Encoding: Element 'Major' has fixed value '2' (value '4' is not allowed) in /includes/modules/shipping/fedexwebservices.php on line 200
In includes/modules/shipping/fedexwebservices.php line 165-242 is below. Line 200 starts at '$av_response = $av_client->addressValidation($av_request);'
Code:
// Address Validation
$residential_address = true;
$address_validation = false;
if (MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_VALIDATION == 'true') {
$path_to_address_validation_wsdl = DIR_WS_MODULES . 'shipping/fedexwebservices/wsdl/AddressValidationService_v2.wsdl';
$av_client = new SoapClient($path_to_address_validation_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$av_request['WebAuthenticationDetail'] = array('UserCredential' =>
array('Key' => $this->fedex_key, 'Password' => $this->fedex_pwd));
$av_request['ClientDetail'] = array('AccountNumber' => $this->fedex_act_num, 'MeterNumber' => $this->fedex_meter_num);
$av_request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Address Validation Request v2 using PHP ***');
$av_request['Version'] = array('ServiceId' => 'aval', 'Major' => '2', 'Intermediate' => '0', 'Minor' => '0');
$av_request['RequestTimestamp'] = date('c');
$av_request['Options'] = array('CheckResidentialStatus' => 1,
'VerifyAddress' => 1,
'MaximumNumberOfMatches' => 10,
'StreetAccuracy' => 'MEDIUM',
'DirectionalAccuracy' => 'MEDIUM',
'CompanyNameAccuracy' => 'MEDIUM',
'ConvertToUpperCase' => 1,
'RecognizeAlternateCityNames' => 1,
'ReturnParsedElements' => 1);
$av_request['AddressesToValidate'] = array(
0 => array(
'AddressId' => 'Customer Address',
'Address' => array(
'StreetLines' => array(utf8_encode($street_address), utf8_encode($street_address2)),
'PostalCode' => $postcode,
'City' => $city,
'StateOrProvinceCode' => $state,
'CompanyName' => $order->delivery['company'],
'CountryCode' => $country_id
)
)
);
try {
$av_response = $av_client->addressValidation($av_request);
/*
//echo '<!--';
echo '<pre>';
print_r($av_response);
echo '</pre>';
//echo '-->';
die();
*/
if ($av_response->HighestSeverity == 'SUCCESS') {
$address_validation = true;
if ($av_response->AddressResults->ProposedAddressDetails->ResidentialStatus == 'BUSINESS') {
$residential_address = false;
} // already set to true so no need for else statement
}
} catch (Exception $e) {
}
}
if ($address_validation == false) {
if ($order->delivery['company'] != '') {
$residential_address = false;
} else {
$residential_address = true;
}
}
$request['RequestedShipment']['Shipper'] = array('Address' => array(
'StreetLines' => array(MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_1, MODULE_SHIPPING_FEDEX_WEB_SERVICES_ADDRESS_2), // Origin details
'City' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_CITY,
'StateOrProvinceCode' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_STATE,
'PostalCode' => MODULE_SHIPPING_FEDEX_WEB_SERVICES_POSTAL,
'CountryCode' => $this->country));
$request['RequestedShipment']['Recipient'] = array('Address' => array (
'StreetLines' => array(utf8_encode($street_address), utf8_encode($street_address2)), // customer street address
'City' => utf8_encode($city), //customer city
//'StateOrProvinceCode' => $state, //customer state
'PostalCode' => $postcode, //customer postcode
'CountryCode' => $country_id,
'Residential' => $residential_address)); //customer county code
if (in_array($country_id, array('US', 'CA'))) {
$request['RequestedShipment']['Recipient']['StateOrProvinceCode'] = $state;
}
//print_r($request['RequestedShipment']['Recipient']) ;
//exit;
Bookmarks