magento UPS TimeInTransit API在没有目的地城市的情况下无法工作

of1yzvn4  于 2022-11-12  发布在  其他
关注(0)|答案(1)|浏览(127)

我正在使用UPS TimeInTransit API通过Magento 2网站上的目的地邮政编码查找估计发货。昨天它已经停止工作,没有给出目的地城市,没有显示结果。之前它工作正常,并根据输入的邮政编码给予我所需的结果。为什么TimeInTransit API不工作,只有目的地邮政编码?
使用代码:

$data ="<?xml version=\"1.0\"?>
        <AccessRequest xml:lang='en-US'>
            <AccessLicenseNumber>111112414134</AccessLicenseNumber>
            <UserId>1213243</UserId>
            <Password>13124123</Password>
       </AccessRequest>
       <?xml version='1.0'?>
        <TimeInTransitRequest xml:lang='en-US'>
          <Request>
            <TransactionReference>
            <CustomerContext>Site Name</CustomerContext>
              <XpciVersion>1.001</XpciVersion>
            </TransactionReference>
            <RequestAction>TimeInTransit</RequestAction>
          </Request>
          <TransitFrom>
            <AddressArtifactFormat>
              <PoliticalDivision2>Lake Elsinore</PoliticalDivision2>
              <PoliticalDivision1>California</PoliticalDivision1>
              <PostcodePrimaryLow>92530</PostcodePrimaryLow>
              <CountryCode>US</CountryCode>
            </AddressArtifactFormat>
          </TransitFrom>
          <TransitTo>
            <AddressArtifactFormat>
              <PoliticalDivision2></PoliticalDivision2>
              <PoliticalDivision1></PoliticalDivision1>
              <PostcodePrimaryLow>92562</PostcodePrimaryLow>
              <CountryCode></CountryCode>
            </AddressArtifactFormat>
          </TransitTo>
          <PickupDate>$today</PickupDate>
          <MaximumListSize>5</MaximumListSize>
          <InvoiceLineTotal>
            <CurrencyCode>USD</CurrencyCode>
            <MonetaryValue>1</MonetaryValue>
          </InvoiceLineTotal>
          <ShipmentWeight>
            <UnitOfMeasurement>
              <Code>$this->weightUnits</Code>
              <Description>Pounds</Description>
            </UnitOfMeasurement>
            <Weight>$packageWeight</Weight>
          </ShipmentWeight>
        </TimeInTransitRequest>";
        // This is the PRODUCTION server -- use when your testing is finished.
        // https://onlinetools.ups.com/ups.app/xml/TimeInTransit
        //This is the TESTING SERVER.
        //https://wwwcie.ups.com/ups.app/xml/TimeInTransit
        $ch = curl_init("https://onlinetools.ups.com/ups.app/xml/TimeInTransit");
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch,CURLOPT_POST,1);
        curl_setopt($ch,CURLOPT_TIMEOUT, 60);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
        $result=curl_exec ($ch);
        //echo '<!-- '. $result. ' -->'; // THIS LINE IS FOR DEBUG PURPOSES ONLY-IT WILL SHOW IN HTML COMMENTS
        $data = strstr($result, '<?');
        $xml = simplexml_load_string($data);
        $json = json_encode($xml);
        $dataArray = json_decode($json,TRUE);

错误响应:[错误] =〉数组([错误严重性] =〉硬[错误代码] =〉270032 [错误说明] =〉无效的目标邮政编码和城市)

lf5gs5x2

lf5gs5x21#

我在TimeInTransit上也遇到了同样的问题,在UPS状态页面或更改日志中找不到任何解释。文档中明确说明城市是可选的。我的代码已经运行多年,在请求中只指定了始发地邮政编码、目的地邮政编码和重量。起初,我收到错误“TimeInTransit中的始发地邮政编码无效”,我通过在XML的PoliticalDivision2中指定始发地城市来解决该问题。(但不是全部)。对于这些请求,我得到了:“无效的目的地邮政编码和城市失败。”一旦我更新了代码,以指定目的地城市以及在政治部门2,它的工作。

相关问题