UPS Time in Transit服务代码到评级API

时间:2014-10-24 07:46:17

标签: php ups ups-api

我正在开发一个使用UPS作为我们打包订单的主要快递的系统。

我使用UPS API发现了一个奇怪的问题。我接受了Time In Transit的所有请求,然后选择客户喜欢的最佳服务。

但是,从Time in Transit API返回的服务列表中选择服务时,我将该服务代码传递给Rating API,并且我一直都会收到此错误:

  

错误代码:111209 - 服务类型无效

我查看过时和过滤时间XML开发人员指南中的附录E - 服务代码部分,但它们似乎都映射不正确...

这是发送的Time in Transit请求:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TimeInTransitRequest xml:lang="en-GB">
    <Request>
        <RequestAction>TimeInTransit</RequestAction>
        <TransactionReference>
            <CustomerContext></CustomerContext>
        </TransactionReference>
    </Request>
    <ShipmentWeight>
        <UnitOfMeasurement>
            <Code>KGS</Code>
        </UnitOfMeasurement>
        <Weight>1</Weight>
    </ShipmentWeight>
    <TransitFrom>
        <AddressArtifactFormat>
            <PoliticalDivision2>Elham</PoliticalDivision2>
            <PoliticalDivision1></PoliticalDivision1>
            <PostcodePrimaryLow>CT46NE</PostcodePrimaryLow>
            <CountryCode>GB</CountryCode>
        </AddressArtifactFormat>
    </TransitFrom>
    <TransitTo>
        <AddressArtifactFormat>
            <PoliticalDivision2></PoliticalDivision2>
            <PoliticalDivision1>CA</PoliticalDivision1>
            <PostcodePrimaryLow>92614</PostcodePrimaryLow>
            <CountryCode>US</CountryCode>
        </AddressArtifactFormat>
    </TransitTo>
    <PickupDate>20141024</PickupDate>
    <TotalPackagesInShipment>1</TotalPackagesInShipment>
    <InvoiceLineTotal>
        <MonetaryValue>255</MonetaryValue>
        <CurrencyCode>GBP</CurrencyCode>
    </InvoiceLineTotal>
</TimeInTransitRequest>

这是API返回的内容:

<?xml version="1.0"?>
<TimeInTransitResponse>
    <Response>
        <TransactionReference></TransactionReference>
        <ResponseStatusCode>1</ResponseStatusCode>
        <ResponseStatusDescription>Success</ResponseStatusDescription>
    </Response>
    <TransitResponse>
        <PickupDate>2014-10-24</PickupDate>
        <TransitFrom>
            <AddressArtifactFormat>
                <PoliticalDivision2>ELHAM</PoliticalDivision2>
                <PoliticalDivision1>KENT</PoliticalDivision1>
                <Country>UNITED KINGDOM</Country>
                <CountryCode>GB</CountryCode>
                <PostcodePrimaryLow>CT046</PostcodePrimaryLow>
            </AddressArtifactFormat>
        </TransitFrom>
        <TransitTo>
            <AddressArtifactFormat>
                <PoliticalDivision2>IRVINE</PoliticalDivision2>
                <PoliticalDivision1>CA</PoliticalDivision1>
                <Country>UNITED STATES</Country>
                <CountryCode>US</CountryCode>
                <PostcodePrimaryLow>92614</PostcodePrimaryLow>
            </AddressArtifactFormat>
        </TransitTo>
        <AutoDutyCode>01</AutoDutyCode>
        <ShipmentWeight>
            <UnitOfMeasurement>
                <Code>KGS</Code>
            </UnitOfMeasurement>
            <Weight>1.0</Weight>
        </ShipmentWeight>
        <InvoiceLineTotal>
            <CurrencyCode>GBP</CurrencyCode>
            <MonetaryValue>255.00</MonetaryValue>
        </InvoiceLineTotal>
        <Disclaimer>All services are guaranteed if shipment is paid for in full by a payee in the United States. Services listed as guaranteed are backed by a money-back guarantee for transportation charges only. See Terms and Conditions in the Service Guide for details. Certain commodities and high value shipments may require additional transit time for customs clearance.</Disclaimer>
        <ServiceSummary>
            <Service>
                <Code>21</Code>
                <Description>UPS Express Plus</Description>
            </Service>
            <Guaranteed>
                <Code>Y</Code>
            </Guaranteed>
            <EstimatedArrival>
                <BusinessTransitDays>1</BusinessTransitDays>
                <Time>08:00:00</Time>
                <PickupDate>2014-10-24</PickupDate>
                <PickupTime>13:00:00</PickupTime>
                <HolidayCount>0</HolidayCount>
                <DelayCount>0</DelayCount>
                <Date>2014-10-27</Date>
                <DayOfWeek>MON</DayOfWeek>
                <TotalTransitDays>3</TotalTransitDays>
                <CustomerCenterCutoff>10:30:00</CustomerCenterCutoff>
                <RestDays>2</RestDays>
            </EstimatedArrival>
        </ServiceSummary>
        <ServiceSummary>
            <Service>
                <Code>01</Code>
                <Description>UPS Express</Description>
            </Service>
            <Guaranteed>
                <Code>Y</Code>
            </Guaranteed>
            <EstimatedArrival>
                <BusinessTransitDays>1</BusinessTransitDays>
                <Time>10:30:00</Time>
                <PickupDate>2014-10-24</PickupDate>
                <PickupTime>13:00:00</PickupTime>
                <HolidayCount>0</HolidayCount>
                <DelayCount>0</DelayCount>
                <Date>2014-10-27</Date>
                <DayOfWeek>MON</DayOfWeek>
                <TotalTransitDays>3</TotalTransitDays>
                <CustomerCenterCutoff>10:30:00</CustomerCenterCutoff>
                <RestDays>2</RestDays>
            </EstimatedArrival>
        </ServiceSummary>
        <ServiceSummary>
            <Service>
                <Code>28</Code>
                <Description>UPS Express Saver</Description>
            </Service>
            <Guaranteed>
                <Code>Y</Code>
            </Guaranteed>
            <EstimatedArrival>
                <BusinessTransitDays>1</BusinessTransitDays>
                <Time>23:30:00</Time>
                <PickupDate>2014-10-24</PickupDate>
                <PickupTime>13:00:00</PickupTime>
                <HolidayCount>0</HolidayCount>
                <DelayCount>0</DelayCount>
                <Date>2014-10-27</Date>
                <DayOfWeek>MON</DayOfWeek>
                <TotalTransitDays>3</TotalTransitDays>
                <CustomerCenterCutoff>10:30:00</CustomerCenterCutoff>
                <RestDays>2</RestDays>
            </EstimatedArrival>
        </ServiceSummary>
        <ServiceSummary>
            <Service>
                <Code>29</Code>
                <Description>UPS Worldwide Express Freight</Description>
            </Service>
            <Guaranteed>
                <Code>Y</Code>
            </Guaranteed>
            <EstimatedArrival>
                <BusinessTransitDays>2</BusinessTransitDays>
                <Time>23:30:00</Time>
                <PickupDate>2014-10-24</PickupDate>
                <PickupTime>13:00:00</PickupTime>
                <HolidayCount>0</HolidayCount>
                <DelayCount>0</DelayCount>
                <Date>2014-10-28</Date>
                <DayOfWeek>TUE</DayOfWeek>
                <TotalTransitDays>4</TotalTransitDays>
                <CustomerCenterCutoff>10:30:00</CustomerCenterCutoff>
                <RestDays>2</RestDays>
            </EstimatedArrival>
        </ServiceSummary>
        <ServiceSummary>
            <Service>
                <Code>05</Code>
                <Description>UPS Expedited</Description>
            </Service>
            <Guaranteed>
                <Code>N</Code>
            </Guaranteed>
            <EstimatedArrival>
                <BusinessTransitDays>4</BusinessTransitDays>
                <Time>23:30:00</Time>
                <PickupDate>2014-10-24</PickupDate>
                <PickupTime>13:00:00</PickupTime>
                <HolidayCount>0</HolidayCount>
                <DelayCount>0</DelayCount>
                <Date>2014-10-30</Date>
                <DayOfWeek>THU</DayOfWeek>
                <TotalTransitDays>6</TotalTransitDays>
                <CustomerCenterCutoff>10:30:00</CustomerCenterCutoff>
                <RestDays>2</RestDays>
            </EstimatedArrival>
        </ServiceSummary>
        <MaximumListSize>35</MaximumListSize>
    </TransitResponse>
</TimeInTransitResponse>

例如,我选择UPS Express Plus服务。服务代码是21,我将其传递给Rate API请求,但是出现了与上面相同的错误。服务代码附加在RatingServiceSelectionRequest/Shipment/Service/Code路径中,如下所示:

<Service>
    <Code>21</Code>
</Service>

我在这里做错了吗?我们的所有订单都可以在全球范围内发送,但始终从英国发货。

2 个答案:

答案 0 :(得分:0)

UPS似乎没有21的服务代码。请查看此文档并尝试其中一个已发布的代码。

http://www.yourecommerce.com/media/UPS_Rates_XML_SDK.pdf

答案 1 :(得分:0)

1

您正在使用“Time in Transit”请求。对此请求的回复不包含“估计运费”。

您应该使用“费率”请求。您可以发布您的费率请求样本吗?

在UPS网站上查看有关“费率”请求的更多信息:https://www.ups.com/upsdeveloperkit/downloadresource?loc=en_US

2

根据2016年1月4日的UPS文件,服务代码 21 请参阅:

说明/类别/路由

  1. UPS Worldwide Express PlusSM /其他货件来自美国/所有

  2. UPS次日Air®早期/货运起源于波多黎各/波多黎各至美国

  3. UPS Worldwide Express PlusSM /货件来自波多黎各/ 其他货物来自波多黎各

  4. UPSExpress®早期/货件起源于加拿大/加拿大至美国

  5. UPS Worldwide Express PlusSM /原产于加拿大的货件/来自加拿大的其他货件

  6. UPS Express Plus /货件来自墨西哥/所有

  7. UPS Worldwide Express PlusSM /货件来自欧盟/欧盟以外的目的地

  8. UPS Worldwide Express PlusSM /来自其他国家/地区的货件