一个项目已将Aramex API集成到系统中以收取运费。 除了一些琐碎的情况,该API正常运行。例如,
如果我将城市用作马尔默,将国家/地区用作瑞典,则会得到运费。
但是当我使用城市作为马尔默,使用国家作为瑞典时,我收到一条消息 Aramex错误-无法获取费率。
这是运费的代码:-
private static function set_shipping_rate_params($shipping_rate_request, $addresses) {
$country_code = Country::find($addresses['shipping_address']['country'])->country_code;
if($country_code == self::$AccountCountryCode) {
self::$ProductType = 'CDS';
self::$ProductGroup = 'DOM';
}
return array(
'Transaction' => array(
'Reference1' => $shipping_rate_request->id
),
'OriginAddress' => array(
'City' => self::$OriginCity,
'CountryCode' => self::$AccountCountryCode
),
'DestinationAddress' => array(
'City' => $addresses['shipping_address']['city'],
'PostCode' => $addresses['shipping_address']['postal'],
'CountryCode' => $country_code
),
'ShipmentDetails' => array(
'PaymentType' => self::$PaymentType,
'ProductGroup' => self::$ProductGroup,
'ProductType' => self::$ProductType,
'ActualWeight' => array( 'Value' => $shipping_rate_request->weight, 'Unit' => 'KG'),
'NumberOfPieces' => $shipping_rate_request->quantity,
'Dimensions' => array(
"Length" => $shipping_rate_request->length,
'Width' => $shipping_rate_request->width,
"Height" => $shipping_rate_request->height,
"Unit" => 'CM')
)
);
}
private static function get_shipping_rate($params) {
$soapClient = new SoapClient(base_path("public/aramex/aramex-rates-calculator-wsdl.wsdl"), array('trace' => 1));
$results = $soapClient->CalculateRate($params);
if(isset($results->TotalAmount) && isset($results->TotalAmount->Value)) {
return $results;
} else {
return 0;
}
}
我该如何解决?