PHP: FedEx shipping rates calculator
FedEx Ship Manager (FSM) Direct was designed to allow customers to connect directly to the FedEx back end systems using their own communications protocol. Welcome to FSM Direct!
You can compose FedEx XML Transactions to interface between your e-commerce application and the FedEx server and vice versa.
This solution is applicable only to those customers that have the development resources and knowledge to develop their own FedEx interface.
Before you begin:
FSM Direct Site Registration: To register in the FSM Direct program, go to http://www.fedex.com/us/solutions/wis/. Register and complete the brief registration form.
Steps for developing your own communications protocol and integrating it into your application are listed below.
- Read and accept the FedEx Ship Manager Direct license agreement.
- Review the FedEx Direct Documentation: Determine if this alternative or FedEx API is appropriate for your application.
- Develop your application.
- Send an email to websupport@fedex.com. Request to be set up for testing. Attach FedEx Express and/or FedEx Ground account number(s).
- Test your application.
All documentation can be found here:
http://www.fedex.com/us/solutions/wis/pdf/fsm_directmanual.pdf
http://www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf
Here’s more about this class
How to use this Fedex rates class:
$fedex->setServer(“https://gatewaybeta.fedex.com/GatewayDC”);
$fedex->setAccountNumber(123123123);
$fedex->setMeterNumber(12312312);
$fedex->setCarrierCode(“FDXE”);
$fedex->setDropoffType(“REGULARPICKUP”);
$fedex->setService($service, $serviceName);
$fedex->setPackaging(“YOURPACKAGING”);
$fedex->setWeightUnits(“LBS”);
$fedex->setWeight(17);
$fedex->setOriginStateOrProvinceCode(“OH”);
$fedex->setOriginPostalCode(44333);
$fedex->setOriginCountryCode(“US”);
$fedex->setDestStateOrProvinceCode(“CA”);
$fedex->setDestPostalCode(90210);
$fedex->setDestCountryCode(“US”);
$fedex->setPayorType(“SENDER”);
$price = $fedex->getPrice();
All available variables can be found here: http://www.fedex.com/us/solutions/wis/pdf/xml_transguide.pdf (FDXRateRequest)
Possible Fedex answer:
(
[server] => https://gatewaybeta.fedex.com/GatewayDC
[accountNumber] => 123123123
[meterNumber] => 12312312
[carrierCode] => FDXE
[dropoffType] => REGULARPICKUP
[service] => STANDARDOVERNIGHT
[serviceName] => FedEx Standard Overnight
[packaging] => YOURPACKAGING
[weightUnits] => LBS
[weight] => 17
[originStateOrProvinceCode] => OH
[originPostalCode] => 44333
[originCountryCode] => US
[destStateOrProvinceCode] => CA
[destPostalCode] => 90210
[destCountryCode] => US
[payorType] => SENDER
[price] => price Object
(
[service] => FedEx Standard Overnight
[rate] => 86.37
[response] => Array
(
…//Here is full xml response
)
)
)
Click here to download FedEx shipping rates calculator class
Please make a donation of 1$ if you find our software useful and want to support the continued development.
Thank you.
19 Responses to 'PHP: FedEx shipping rates calculator'
Leave a Reply
You must be logged in to post a comment.
on August 10th, 2006 at 11:57 pm
We have a FedEx account number, but I’m not sure what the ‘meterNumber’ is? How can I obtain that - I really need to get this working soon.
Thanks
on September 2nd, 2006 at 3:51 pm
I either don’t know what is meterNumber. You should ask it at fedex support, but when I was developing this class – meterNumber was not necessary.
on September 14th, 2006 at 7:34 pm
A meter number is used in conjunction with your account number. For rating purposes the meter number is optional. If you use the Direct for producing labels, and some other functionalities, the meter is required. You can obtain a meter by sending a subscribe transaction to the test server. Once you are in production, you will need to repeat that step to get your production meter.
on October 10th, 2006 at 9:35 pm
Hi Guys, i’m using the Fedex Shipping Rate Calculation, it seams to work fine, but when i try to make a Fedex Ground it returns to me error message saying that “Invalid service type” Error #16470″ did anyone have these problem??
Thanx a lot
Andre Tozzini
on October 11th, 2006 at 9:10 am
I either don’t know what the problem could it be. You should contact Fedex and ask them what is the problem with Fedex Ground service type.
on October 12th, 2006 at 1:30 am
Thanx Algirdas….
I will contact the Fedex Guys….
Cya
Andre Tozzini
on August 31st, 2007 at 1:22 pm
[…] After this I found few bugs witch I fixed and now you can download updated FedEx class from this post. […]
on September 28th, 2007 at 11:09 pm
[…] You can download updated FedEx class from this post. […]
on October 31st, 2007 at 12:41 am
This is in reply to a comment from just over a year ago, but for future downloads. If you’re Ground shipping, you need to change the following line from this…
$fedex->setCarrierCode(“FDXE”);
to this…
$fedex->setCarrierCode(“FDXG”);
on November 2nd, 2007 at 6:53 pm
all i’m getting is a 16501 error… could not communicate with mainframe. at first i thought it was maybe on their end, so i waited a day and it still says that. any suggestions?
http://dev.koboseattle.com/Fedex/index.php
on November 2nd, 2007 at 7:06 pm
Look at comment above
You are trying to get rates for ground service but carrier code is set to express, so you should use $fedex->setCarrierCode(“FDXG”); and everything will be ok.
on November 2nd, 2007 at 7:16 pm
Genius! Sorry about that, I set it properly in the class, just not in the page calling the class.
on December 13th, 2007 at 12:36 am
The script looks great, but I was wondering how you go about submitting the request to get your meter number?
on June 5th, 2008 at 12:10 pm
Hello Algirdas,
first of all many thanks that you share your skills with us!
It´s my first time I shall intergrate the FedEx Rate Modul in a selfmade shopping cart.
My question:
How can I use the variables from the price object as single output?
I only need the “rate” and the “service”, so I build these request at the end of index.php.
if(is_object($wert)){
foreach($wert as $eintrag) {
if(is_object($eintrag) || is_array($eintrag)){
echo ”;
}
else {
echo $eintrag.”;
}
}
}
}
At the end of fedex.php I changed “print_r($this);” into “return $this;”.
It´s my first time I work with classes and objects, so it´s difficult for me to understand the complete script.
Hope you can help me.
Thank you and best regards,
Martin
on June 12th, 2008 at 6:36 pm
Martin
Have you found an answer? I’m in the same boat.
Also the the publisher the change for the ground issue doesn’t work while in test. Is it just the test mode problem?
Thanks
Nick
on June 12th, 2008 at 6:48 pm
if you call
then you will be able to print rate
on June 25th, 2008 at 12:02 pm
Hi
From my local PC i can access all information from fedex.com using this class but when i m trying to collect information then i can’t get.
Whats the problem?
Please help me.
Thnaks
on June 25th, 2008 at 12:48 pm
Looks like you server does not have curl lib.
http://lt2.php.net/curl
on November 5th, 2008 at 3:22 am
Does anyone know how to get time in transit for ground using this script? The script uses Rate Available Services and I guess that using Service Availability gives you transit time.