![]() |
![]() |
![]() |
![]() |
|
| |
|
|
|
|
|
|
|
|
INPUTS |
AUCTIONINC SERVER TASKS |
OUTPUTS |
| destination country & postal code | 1) validate access key | ship rates for each requested service |
| item weight / dimensions / quantity | 2) look up account configuration (SS calls) | errors returned from carrier APIs |
| item declared value | 3) determine best packaging | |
| requested carrier services (XS calls) | 4) call carrier APIs and calculate rates | |
| 5) construct response XML |
Saved Settings (SS) vs XML Settings (XS) Calls
Saved Settings-based (SS) calls require pre-configuration of shipping preferences prior to making calls, but in exchange for this additional step, a variety of features are offered which are not available when making XML Settings (XS) calls.
These include:
MAKING THE CALLS
Construction of XML Calls
The Request XML is made up of two main elements: the RequestHeader and the RequestBody. Both of these elements are contained within an Envelope root element. The RequestHeader contains the AccountID element, which is used to identify the caller, reference any saved preferences, and provide for accounting data. The RequestBody will contain an element for the method call (along with a version number), and inside that element additional nodes or elements will supply any necessary arguments to support the method invoked.
<?xml version="1.0 encoding=iso-8859-1" utf-8 ?>
<Envelope>
<Header>
<AccountId>your account id</AccountId>
</Header>
<Body>
<GetTime version="2.0">
</GetTime>
</Body>
</Envelope>
Sending the Request
Once the XML request has been properly constructed, it needs to be submitted to the AuctionInc Web Service utilizing standard HTTP POST protocol. The POST request should be formatted similar to the following example:
POST /websvc/shire HTTP/1.0
HOST: api.auctioninc.com
Connection: Close Content-Type: text/xml
Content-Length: 262
Your XML String
<?xml version="1.0" encoding="utf-8" ?>
<Envelope>
<Header>
<AccountId>your account id</AccountId>
</Header>
<Body>
<GetItemShipRateSS version="2.1">
<DetailLevel>1</DetailLevel>
<Currency>USD</Currency>
<DestinationAddress>
<ResidentialDelivery>true</ResidentialDelivery>
<CountryCode>US</CountryCode>
<PostalCode>90210</PostalCode>
<StateOrProvinceCode>CA</StateOrProvinceCode >
</DestinationAddress>
<ItemList>
<Item>
<RefCode>keyboard-101</RefCode>
<Quantity>2</Quantity>
<CalcMethod code="C">
<CarrierCalcProps>
<OriginCode>your defined origin code, if any</OriginCode>
<Weight>4</Weight>
<WeightUOM>LBS</WeightUOM>
<DeclaredValue>59.95</DeclaredValue>
<PackMethod>T</PackMethod>
</CarrierCalcProps>
</CalcMethod>
</Item>
</ItemList>
</GetItemShipRateSS>
</Body>
</Envelope>
<?xml version="1.0" encoding="utf-8" ?>
<Envelope>
<Header>
<AccountId>your account id</AccountId>
</Header>
<Body>
<GetItemShipRateXS version="2.1">
<DetailLevel>1</DetailLevel>
<Currency>USD</Currency>
<CarrierList>
<Carrier code="UPS">
<EntryPoint>P</EntryPoint>
<ServiceList>
<Service code="UPSGND">
<PkgWeightMax>50</PkgWeightMax>
</Service>
<Service code="UPSNDA" />
</ServiceList>
</Carrier>
<Carrier code="DHL">
<EntryPoint>D</EntryPoint>
<AccessKey>your DHL access key</AccessKey>
<PostalCode>01610</PostalCode>
<ServiceList>
<Service code="DHLGND" />
<Service code="DHLNDA" />
</ServiceList>
</Carrier>
<Carrier code="USPS">
<FlatRatePackaging>ENV</FlatRatePackaging>
<ServiceList>
<Service code="USPEXP" />
<Service code="USPMM">
<OnDemand>true</OnDemand>
</Service>
</ServiceList>
</Carrier>
</CarrierList>
<OriginAddressList>
<OriginAddress>
<OriginCode>MA-RTS</OriginCode>
<CountryCode>US</CountryCode>
<PostalCode>01610</PostalCode>
<StateOrProvinceCode>MA</StateOrProvinceCode>
</OriginAddress>
<OriginAddress>
<OriginCode>CA-WHS</OriginCode>
<CountryCode>US</CountryCode>
<PostalCode>90210</PostalCode>
<StateOrProvinceCode>CA</StateOrProvinceCode>
</OriginAddress>
</OriginAddressList>
<DestinationAddress>
<ResidentialDelivery>true</ResidentialDelivery>
<CountryCode>US</CountryCode>
<PostalCode>90210</PostalCode>
<StateOrProvinceCode>CA</StateOrProvinceCode >
</DestinationAddress>
<ItemList>
<Item>
<RefCode>Compact Disk</RefCode>
<Quantity>2</Quantity>
<CalcMethod code="C">
<CarrierCalcProps>
<Length>2</Length>
<Width>10</Width>
<Height>2.5</Height>
<DimUOM>IN</DimUOM>
<Weight>4</Weight>
<WeightUOM>LBS</WeightUOM>
<DeclaredValue>59.95</DeclaredValue>
<PackMethod>T</PackMethod>
<OriginCode>MA-RTS</OriginCode>
<OnDemandServices>
<ODService>USPMM</ODService>
</OnDemandServices>
</CarrierCalcProps>
</CalcMethod>
</Item>
<Item>
<RefCode>Instruction Book</RefCode>
<Quantity>1</Quantity>
<CalcMethod code="C">
<CarrierCalcProps>
<Length>6</Length>
<Width>1</Width>
<Height>8</Height>
<DimUOM>IN</DimUOM>
<Weight>1.5</Weight>
<WeightUOM>LBS</WeightUOM>
<DeclaredValue>29.95</DeclaredValue>
<PackMethod>S</PackMethod>
<OriginCode>CA-WHS</OriginCode>
<OnDemandServices>
<ODService>USPMM</ODService>
</OnDemandServices>
</CarrierCalcProps>
</CalcMethod>
</Item>
</ItemList>
</GetItemShipRateXS>
</Body>
</Envelope>
Debugging Your API Calls
Here is an article in our knowledgebase detailing some debugging strategies, along with a form you can use to directly test the API:
Troubleshooting the Shipping Calculator API
Managing the Response XML
Testing for Success
The HTTP response code should first be tested for "200 OK" to ensure that your API call was successfully invoked.
Sample Rating Response XML (Detail Level = 1):
<?xml version="1.0" encoding="utf-8" ?>
<Envelope> <Header>
<Date>2008-10-28 19:53:14 GMT</Date>
</Header> <Body>
<ItemShipRate>
<Currency>USD</Currency>
<ShipRateList>
<ShipRate>
<Valid>1</Valid>
<CarrierCode>USPS</CarrierCode>
<ServiceCode>USPSPM</ServiceCode>
<ServiceName>PriorityMail</ServiceName>
<CalcMethod>C</CalcMethod>
<Rate>48.26</Rate>
</ShipRate>
<ShipRate>
<Valid>1</Valid>
<CarrierCode>UPS</CarrierCode>
<ServiceCode>UPSGND</ServiceCode>
<ServiceName>Ground</ServiceName>
<CalcMethod>C</CalcMethod>
<Rate>31.21</Rate>
</ShipRate>
</ShipRateList>
</ItemShipRate>
</Body>
</Envelope>
<?xml version="1.0 encoding=iso-8859-1" utf-8 ?>-Type 2 Errors are for a particular carrier service which for some reason is unable to provide rates for a given item/destination. The error node will appear inside the Carrier node. These errors can be handled by you according to your preference.
<Envelope>
<Header> <AccountId>your access key</AccountId> </Header> <Body> <Error> <Code>560</Code> <Message>Invalid Account Id</Message> <Severity>CRITICAL</Severity> </Error> </Body> </Envelope>
<?xml version="1.0 encoding=iso-8859-1" utf-8 ?>
<Envelope>
<Header> <AccountId>your access key</AccountId> </Header> <Body>
<ItemShipRate>
... <ShipRate> <Valid>False</Valid> <CarrierCode>USPS</CarrierCode> <ServiceCode>USPSPP</ServiceCode> <ServiceName>Parcel Post</ServiceName> <CalcMethod>CARRIER></Carrier> <Rate></Rate> <ErrorList> <Error> <Code>710</Code> <Message>Item exceeds maximum weight</Message> <Severity>NOTICE</Severity> </Error> </ErrorList> </ShipRate> ... </ItemShipRate> </Body> </Envelope>
|
Saved Settings (SS) Calls |
XML Settings (XS) Calls |
| origin address | |
| destination address | destination address |
| currency (default: USD) | currency (default: USD) |
| calculation method | calculation method |
| item origin code (optional) | item origin code (optional) |
| item quantity | item quantity |
| item lot size | item lot size |
| item weight | item weight |
| item dimensions (optional) | item dimensions (optional) |
| units of measures for weight and dims |
unit of measures for weight and dims |
| item declared value | item declared value |
| item package method | item package method |
| supplemental item handling fee (optional) | supplemental item handling fee (optional) |
| on demand flag (optional) | carriers to rate |
| special carrier services (optional) | carrier entry points |
|
item fixed fee codes (for fixed fee ratings) |
carrier services to rate |
|
supplemental item handling fee codes (optional) |
carrier services package weight maximums (optional) |
| DHL only: carrier access key & postal code | |
| USPS only: flat rate packaging flag (optional) | |
| special carrier services (optional) | special carrier services (optional) |
PHP Toolkit
We have an SDK available for php that you can download. This will handle the communications to and from the API, the creation of your outgoing XML and the parsing of our incoming XML. Your remaining tasks will essentially be to gather the necessary item data from the items in your cart, and to integrate the returned rates back into your cart.
Best Practices
Coding for XS calls requires data collection from your sellers so that you can include that data in your calls. The four general data categories are:
| Home | About Us | Contact Us | Partnerships | User Agreement | Privacy Policy | ||
|
Copyright © 2009 AuctionInc. A division of Paid, Inc. Paid Inc. 4 Brussels St, Worcester, MA 01610. 1-866-323-8833. |