I've got a working request to get rates for my shipment using standard Fedex rates, but I want to use the special Fedex One Rate option so that I can get their flat rate quotes.
Unfortunately, their code example doesn't show how to specify the Rate Request should use Fedex One Rate and I've been completely unable to mentally parse through the xml vomit that is WSDL. I've tried several different array structures to pass (what I assume) are the right variables, but nothing works.
I generated two html versions of the WSDL using 3rd party generators (neither is incredibly helpful, but maybe you can read them better than I).
The first includes the wsdl directly with data types linked to their definitions: http://inadaydevelopment.com/stackoverflow/fedex/RateService_v16.html
The second is more basic, it just provides the hierarchy in a more linear fashion with the valid values at each level: http://inadaydevelopment.com/stackoverflow/fedex/RateService_v16_other.html
As far as I can tell, there are two ways/places I can declare that I want my rate quote to use One Rate:
1) $request['VariableOptions'] = 'FEDEX_ONE_RATE';
and
2) $request['RequestedShipment']['SpecialServicesRequested'] = array(
'SpecialServiceTypes' => array('FEDEX_ONE_RATE')
);
When I use (1), I get a success response that includes a list of prices, but they aren't the One Rate prices. They are the standard prices.
When I use (2), I get a fail response:
stdClass Object
(
[HighestSeverity] => WARNING
[Notifications] => stdClass Object
(
[Severity] => WARNING
[Source] => crs
[Code] => 556
[Message] => There are no valid services available.
[LocalizedMessage] => There are no valid services available.
)
[TransactionDetail] => stdClass Object
(
[CustomerTransactionId] => *** Service Availability Request v5.1 using PHP ***
)
[Version] => stdClass Object
(
[ServiceId] => crs
[Major] => 16
[Intermediate] => 0
[Minor] => 0
)
)
If I use both (1) and (2), then I get the (2) error message as well as an additional warning saying that I specified One Rate in two different ways and that (2) was going to override (1).
Here is my full request array:
array (
'WebAuthenticationDetail' =>
array (
'UserCredential' =>
array (
'Key' => 'xxx',
'Password' => 'xxx',
),
),
'ClientDetail' =>
array (
'AccountNumber' => 'xxx',
'MeterNumber' => 'xxx',
),
'TransactionDetail' =>
array (
'CustomerTransactionId' => ' *** Service Availability Request v5.1 using PHP ***',
),
'Version' =>
array (
'ServiceId' => 'crs',
'Major' => '16',
'Intermediate' => '0',
'Minor' => '0',
),
'ReturnTransitAndCommit' => true,
'RequestedShipment' =>
array (
'DropoffType' => 'STATION',
'ShipTimestamp' => '2015-06-14T14:13:46-07:00',
'Shipper' =>
array (
'Contact' =>
array (
'PersonName' => 'Kenny Wyland',
'CompanyName' => 'K2 Cashflow',
'PhoneNumber' => 'xxxxxxxxxx',
),
'Address' =>
array (
'StreetLines' =>
array (
0 => 'xxxx E xxxxx St',
),
'City' => 'Long Beach',
'StateOrProvinceCode' => 'CA',
'PostalCode' => '90805',
'CountryCode' => 'US',
),
),
'Recipient' =>
array (
'Contact' =>
array (
'PersonName' => 'Bob Smith',
'PhoneNumber' => 'xxx-xxx-xxxx',
),
'Address' =>
array (
'StreetLines' =>
array (
0 => 'xxxxx xxxxxxx Rd',
),
'City' => 'Corona',
'StateOrProvinceCode' => 'CA',
'PostalCode' => '92883',
'CountryCode' => 'US',
'Residential' => true,
),
),
'ShippingChargesPayment' =>
array (
'PaymentType' => 'SENDER',
'Payor' =>
array (
'ResponsibleParty' =>
array (
'AccountNumber' => 'xxxx',
'Contact' => NULL,
'Address' =>
array (
'CountryCode' => 'US',
),
),
),
),
'PackageCount' => '1',
'RequestedPackageLineItems' =>
array (
0 =>
array (
'SequenceNumber' => 1,
'GroupPackageCount' => 1,
'Weight' =>
array (
'Value' => 0.01,
'Units' => 'LB',
),
),
),
'SpecialServicesRequested' =>
array (
'SpecialServiceTypes' =>
array (
0 => 'FEDEX_ONE_RATE',
),
),
),
)
The document https://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201408/RateServicesWSDLGuide_v2014.pdf, point 2.4.4 states that there are several requirements to get One Rate pricing:
- Specify the "FEDEX_ONE_RATE" ShipmentSpecialService.
Which you already have (the one that you use is specified in FedEx Freight Priority and FedEx Freight Economy, point 2.2.4.1).
The next requirement:
- Specify one of the following Packaging Types:
FEDEX_SMALL_BOX
....
In code it should be:
$request['RequestedShipment']['PackagingType'] = 'FEDEX_SMALL_BOX';
After that comes the 3rd requirement:
- Specify a U.S. origin and a U.S. destination.
Which you already have in your code.
And the 4th requirement:
- Specify one of the following FedEx Express services:
FIRST_OVERNIGHT
...
Which is in code:
$request['RequestedShipment']['ServiceType'] = 'FIRST_OVERNIGHT';
Also, pay attention to the note at the end:
*Note: Web Services clients can request both One Rate and weight-based (non-One Rate) rates in a single RateRequest by specifying "FEDEX_ONE_RATE" as a ServiceOptionType in the RateRequest.variableOptions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With