使用 Fedex API RateService 指定 Fedex One Rate 的数组结构

Array structure to specify Fedex One Rate using Fedex API RateService

我有一个使用标准 Fedex 费率获取我的货件费率的工作请求,但我想使用特殊的 Fedex One Rate 选项以便我可以获得他们的统一费率报价。

不幸的是,他们的代码示例没有显示如何指定费率请求应该使用 Fedex One Rate,而且我已经完全无法在精神上解析 WSDL 的 xml 呕吐物。我尝试了几种不同的数组结构来传递(我假设的)是正确的变量,但没有任何效果。

我使用第 3 方生成器生成了两个 html 版本的 WSDL(两者都不是非常有用,但也许您比我更能读懂它们)。

第一个直接包含 wsdl,数据类型链接到它们的定义:http://inadaydevelopment.com/Whosebug/fedex/RateService_v16.html

第二个更基本,它只是以更线性的方式提供层次结构,每个级别都有有效值:http://inadaydevelopment.com/Whosebug/fedex/RateService_v16_other.html

据我所知,有两个 ways/places 我可以声明我希望我的费率报价使用一个费率:

1) $request['VariableOptions'] = 'FEDEX_ONE_RATE';

2) $request['RequestedShipment']['SpecialServicesRequested'] = array(
    'SpecialServiceTypes' => array('FEDEX_ONE_RATE')
);

当我使用 (1) 时,我得到了包含价格列表的成功响应,但它们不是单一费率价格。它们是标准价格。

当我使用 (2) 时,我收到失败响应:

stdClass Object
(
    [HighestSeverity] => WARNING
    [Notifications] => stdClass Object
        (
            [Severity] => WARNING
            [Source] => crs
            [Code] => 556
            [Message] => There are no valid services available. 
            [LocalizedMessage] => There are no valid services available. 
        )

    [TransactionDetail] => stdClass Object
        (
            [CustomerTransactionId] =>  *** Service Availability Request v5.1 using PHP ***
        )

    [Version] => stdClass Object
        (
            [ServiceId] => crs
            [Major] => 16
            [Intermediate] => 0
            [Minor] => 0
        )

)

如果我同时使用 (1) 和 (2),则会收到 (2) 错误消息以及一条额外的警告,说明我以两种不同的方式指定了 One Rate,而 (2) 将覆盖 (1).

这是我的完整请求数组:

array (
  'WebAuthenticationDetail' => 
  array (
    'UserCredential' => 
    array (
      'Key' => 'xxx',
      'Password' => 'xxx',
    ),
  ),
  'ClientDetail' => 
  array (
    'AccountNumber' => 'xxx',
    'MeterNumber' => 'xxx',
  ),
  'TransactionDetail' => 
  array (
    'CustomerTransactionId' => ' *** Service Availability Request v5.1 using PHP ***',
  ),
  'Version' => 
  array (
    'ServiceId' => 'crs',
    'Major' => '16',
    'Intermediate' => '0',
    'Minor' => '0',
  ),
  'ReturnTransitAndCommit' => true,
  'RequestedShipment' => 
  array (
    'DropoffType' => 'STATION',
    'ShipTimestamp' => '2015-06-14T14:13:46-07:00',
    'Shipper' => 
    array (
      'Contact' => 
      array (
        'PersonName' => 'Kenny Wyland',
        'CompanyName' => 'K2 Cashflow',
        'PhoneNumber' => 'xxxxxxxxxx',
      ),
      'Address' => 
      array (
        'StreetLines' => 
        array (
          0 => 'xxxx E xxxxx St',
        ),
        'City' => 'Long Beach',
        'StateOrProvinceCode' => 'CA',
        'PostalCode' => '90805',
        'CountryCode' => 'US',
      ),
    ),
    'Recipient' => 
    array (
      'Contact' => 
      array (
        'PersonName' => 'Bob Smith',
        'PhoneNumber' => 'xxx-xxx-xxxx',
      ),
      'Address' => 
      array (
        'StreetLines' => 
        array (
          0 => 'xxxxx xxxxxxx Rd',
        ),
        'City' => 'Corona',
        'StateOrProvinceCode' => 'CA',
        'PostalCode' => '92883',
        'CountryCode' => 'US',
        'Residential' => true,
      ),
    ),
    'ShippingChargesPayment' => 
    array (
      'PaymentType' => 'SENDER',
      'Payor' => 
      array (
        'ResponsibleParty' => 
        array (
          'AccountNumber' => 'xxxx',
          'Contact' => NULL,
          'Address' => 
          array (
            'CountryCode' => 'US',
          ),
        ),
      ),
    ),
    'PackageCount' => '1',
    'RequestedPackageLineItems' => 
    array (
      0 => 
      array (
        'SequenceNumber' => 1,
        'GroupPackageCount' => 1,
        'Weight' => 
        array (
          'Value' => 0.01,
          'Units' => 'LB',
        ),
      ),
    ),
    'SpecialServicesRequested' => 
    array (
      'SpecialServiceTypes' => 
      array (
        0 => 'FEDEX_ONE_RATE',
      ),
    ),
  ),
)

文档 https://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201408/RateServicesWSDLGuide_v2014.pdf 的第 2.4.4 点指出,要获得单一费率定价有几个要求:

  1. Specify the "FEDEX_ONE_RATE" ShipmentSpecialService.

您已经拥有的(您使用的是在 FedEx Freight Priority 和 FedEx Freight Economy 中指定的,第 2.2.4.1 点)。

下一个要求:

  1. Specify one of the following Packaging Types:

FEDEX_SMALL_BOX

....

在代码中应该是:

$request['RequestedShipment']['PackagingType'] = 'FEDEX_SMALL_BOX';

之后是第三个要求:

  1. Specify a U.S. origin and a U.S. destination.

您的代码中已有。

第四个要求:

  1. Specify one of the following FedEx Express services:

FIRST_OVERNIGHT

...

在代码中:

$request['RequestedShipment']['ServiceType'] = 'FIRST_OVERNIGHT';

另外,注意最后的注释:

*Note: Web Services clients can request both One Rate and weight-based (non-One Rate) rates in a single RateRequest by specifying "FEDEX_ONE_RATE" as a ServiceOptionType in the RateRequest.variableOptions.