gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 02:36:16 24 4
gpt4 key购买 nike

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

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

我使用第 3 方生成器生成了 WSDL 的两个 html 版本(都不是非常有帮助,但也许您可以比我更好地阅读它们)。

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

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

据我所知,我可以通过两种方式/地方声明我希望我的费率报价使用单一费率:

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) 错误消息以及一条附加警告,指出我以两种不同的方式指定了单一速率,并且 (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 cargo 优先级和 FedEx cargo 经济,第 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.

关于php - 使用 Fedex API RateService 指定 Fedex One Rate 的数组结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30811962/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com