com.konakart.bl.modules.shipping.usps
Class Usps
java.lang.Object
com.konakart.bl.modules.BaseModule
com.konakart.bl.modules.shipping.BaseShippingModule
com.konakart.bl.modules.shipping.usps.Usps
- All Implemented Interfaces:
- ShippingInterface
public class Usps
- extends BaseShippingModule
- implements ShippingInterface
This shipping module communicates with USPS to retrieve shipping rates. Using the Admin App you
must set up the following configuration variables:
USPS Module:
- USPS User Id which you need to receive from USPS
- Request URL (production: http://production.shippingapis.com/ShippingAPI.dll)
- USPS Service code. This is the code for the service that you want. Valid codes are:
- ALL - Returns all available rates
- FIRST CLASS
- PRIORITY
- PRIORITY COMMERCIAL
- EXPRESS
- EXPRESS SH
- EXPRESS HFP
- EXPRESS COMMERCIAL
- EXPRESS SH COMMERCIAL
- EXPRESS HFP COMMERCIAL
- PARCEL POST
- BPM
- MEDIA MAIL
- LIBRARY MAIL
- USPS Service codes to exclude. You could ask for all rates but decide to exclude certain
ones. The excluded rates are defined by comma separated codes. The codes are:
- 0 First-Class
- 1 Priority Mail
- 2 Express Mail Hold for Pickup
- 3 Express Mail PO to Addressee
- 4 Parcel Post
- 5 Bound Printed Matter
- 6 Media Mail
- 7 Library
- 12 First-Class Postcard Stamped
- 13 Express Mail Flat-Rate Envelope
- 16 Priority Mail Flat-Rate Envelope
- 17 Priority Mail Flat-Rate Box
- 18 Priority Mail Keys and IDs
- 19 First-Class Keys and IDs
- 22 Priority Mail Flat-Rate Large Box
- 23 Express Mail Sunday/Holiday
- 25 Express Mail Flat-Rate Envelope Sunday/Holiday
- 27 Express Mail Flat-Rate Envelope Hold For Pickup
- Size by weight. For many of the rates, UPS requires a size to be specified. Valid values are:
This configuration variable allows you to specify different sizes based on the weight of the
delivery. The formatting should look something like this: 10:REGULAR,25:LARGE,71:OVERSIZE which
means that a REGULAR size is used from 0 to 9lbs, a LARGE size from 10lbs to 24lbs and an
OVERSIZE size from 25lbs to 70lbs.
- Container Type defines the type of container used for the package. Valid values are:
- RECTANGULAR
- NONRECTANGULAR
- LG FLAT RATE BOX
- FLAT RATE BOX
- FLAT RATE ENV.
- LG FLAT RATE BOX
- VARIABLE
- Machinable Package can be set to true or false. The USPS definitions for machinable can be
found here: http://pe.usps.com/text/dmm300/101.htm
- When First Class is selected, the package must be LETTER, FLAT or PARCEL.
- Handling fee : Defaults to 0. It is added to the charge returned by USPS.
Shipping and Packaging under Configuration
- Country of Origin : Country from which packages will be shipped.
- Postal Code : Postal code of area from which packages will be shipped
- Maximum package weight : This is used to split the order into multiple packages . We make
multiple calls to USPS and sum the costs to create a total.
- Package tare weight : This is added to the weight of the items being shipped per package
|
Nested Class Summary |
protected class |
Usps.StaticData
Used to store the static data of this module |
| Methods inherited from class com.konakart.bl.modules.BaseModule |
getBasketMgr, getCatMgr, getConfigMgr, getCurrMgr, getCustMgr, getEmailMgr, getEng, getLangMgr, getMultiStoreMgr, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getPromMgr, getResourceBundle, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getTaxMgr, init, isAvailable |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Usps
public Usps(KKEngIf eng)
throws org.apache.torque.TorqueException,
KKException,
com.workingdogs.village.DataSetException
- Constructor
- Parameters:
eng -
- Throws:
com.workingdogs.village.DataSetException
KKException
org.apache.torque.TorqueException
getQuote
public ShippingQuote getQuote(Order order,
ShippingInfo info)
throws java.lang.Exception
- We get a quote from USPS. If we only get one quote back then we return a ShippingQuote object
with the details of the quote. If we get back more than one quote then we create an array of
ShippingQuote objects and attach them to the ShippingQuote object that we return. In this
case all of the quotes must be in the array since the quote itself isn't processed.
It becomes more complex when we have the shipment split into a number of packages. The split
is done by the manager calling this method and is presented to us in an orderWeightList. For
each item in the list, we call USPS and get back one or more quotes. We then have to add up
the quotes and return them as single quotes that can be displayed on the screen.
- Specified by:
getQuote in interface ShippingInterface
- Parameters:
order - The order object
- Returns:
- Returns a ShippingQuote object
- Throws:
java.lang.Exception
isAvailable
public boolean isAvailable()
throws KKException
- Returns true or false
- Specified by:
isAvailable in interface ShippingInterface
- Returns:
- True or False
- Throws:
KKException
setStaticVariables
public void setStaticVariables()
throws KKException
- Sets some static variables during setup
- Specified by:
setStaticVariables in interface ShippingInterface
- Throws:
KKException
Copyright © 2011 DS Data Systems UK Ltd.