1

我已经在 Google 和 Stackoverlow 上搜索了很多人似乎遇到的这个问题,但没有一个明确的答案。

我使用的是 Opencart vs 1.5.5.1,并且 Fedex 模块在结帐时不显示任何运输选项,它只是显示错误。

我已验证我的密钥、密码、帐户和仪表编号正确。我使用的是生产帐户,而不是测试帐户。以下是我发送到的确切 XML(已删除敏感信息):https ://gateway.fedex.com/web-services/

<?xml version="1.0"?>
<soap-env:envelope xmlns:ns1="http://fedex.com/ws/rate/v10" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    <soap-env:body>
        <ns1:raterequest>
            <ns1:webauthenticationdetail>
                <ns1:usercredential>
                    <ns1:key>ThisIsMyKey</ns1:key>
                    <ns1:password>ThisIsMyPassword</ns1:password>
                </ns1:usercredential>
            </ns1:webauthenticationdetail>
            <ns1:clientdetail>
                <ns1:accountnumber>123456789</ns1:accountnumber>
                <ns1:meternumber>987654321</ns1:meternumber>
            </ns1:clientdetail>
            <ns1:version>
                <ns1:serviceid>crs</ns1:serviceid>
                <ns1:major>10</ns1:major>
                <ns1:intermediate>0</ns1:intermediate>
                <ns1:minor>0</ns1:minor>
            </ns1:version>
            <ns1:returntransitandcommit>true</ns1:returntransitandcommit>
            <ns1:requestedshipment>
                <ns1:shiptimestamp>2013-09-11T11:35:31-05:00</ns1:shiptimestamp>
                <ns1:dropofftype>REGULAR_PICKUP</ns1:dropofftype>
                <ns1:packagingtype>FEDEX_ENVELOPE</ns1:packagingtype>
                <ns1:shipper>
                    <ns1:contact>
                        <ns1:personname>Jägermein</ns1:personname>
                        <ns1:companyname>Jägermein</ns1:companyname>
                        <ns1:phonenumber>123-456-7890</ns1:phonenumber>
                    </ns1:contact>
                    <ns1:address>
                        <ns1:stateorprovincecode>IL</ns1:stateorprovincecode>
                        <ns1:postalcode>61422</ns1:postalcode>
                        <ns1:countrycode>US</ns1:countrycode>
                    </ns1:address>
                </ns1:shipper>
                <ns1:recipient>
                    <ns1:contact>
                        <ns1:personname>test test</ns1:personname>
                        <ns1:companyname></ns1:companyname>
                        <ns1:phonenumber></ns1:phonenumber>
                    </ns1:contact>
                    <ns1:address>
                        <ns1:streetlines>test</ns1:streetlines>
                        <ns1:city>test</ns1:city>
                        <ns1:stateorprovincecode>IL</ns1:stateorprovincecode>
                        <ns1:postalcode>61554</ns1:postalcode>
                        <ns1:countrycode>US</ns1:countrycode>
                        <ns1:residential>false</ns1:residential>
                    </ns1:address>
                </ns1:recipient>
                <ns1:shippingchargespayment>
                    <ns1:paymenttype>SENDER</ns1:paymenttype>
                    <ns1:payor>
                        <ns1:accountnumber>123456789</ns1:accountnumber>
                        <ns1:countrycode>US</ns1:countrycode>
                    </ns1:payor>
                </ns1:shippingchargespayment>
                <ns1:raterequesttypes>LIST</ns1:raterequesttypes>
                <ns1:packagecount>1</ns1:packagecount>
                <ns1:requestedpackagelineitems>
                    <ns1:sequencenumber>1</ns1:sequencenumber>
                    <ns1:grouppackagecount>1</ns1:grouppackagecount>
                    <ns1:weight>
                        <ns1:units>LB</ns1:units>
                        <ns1:value>19.541</ns1:value>
                    </ns1:weight>
                    <ns1:dimensions>
                        <ns1:length>20</ns1:length>
                        <ns1:width>20</ns1:width>
                        <ns1:height>10</ns1:height>
                        <ns1:units>IN</ns1:units>
                    </ns1:dimensions>
                </ns1:requestedpackagelineitems>
            </ns1:requestedshipment>
        </ns1:raterequest>
    </soap-env:body>
</soap-env:envelope>

Opencart 通过 CURL 发送此请求,如下所示:

$curl = curl_init($url);  
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);

如果我var_dump响应它给我以下信息: ERRORERRORprof1000Authentication Failed crs 10 0 0

问题可能出在哪里?

4

2 回答 2

0

我已修复 Fedex 未显示错误

请找到文件目录/model/shipping/fedex.php

如果您在之后看到错误,请用我的代码更改代码,然后不要忘记检查您的产品重量

<?php
class ModelShippingFedex extends Model {
function getQuote($address) {
$this->load->language('shipping/fedex');

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('fedex_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

if (!$this->config->get('fedex_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}    

$error = '';

$quote_data = array();

if ($status) {
$weight = $this->weight->convert($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->config->get('fedex_weight_class_id'));
$weight_code = strtoupper($this->weight->getUnit($this->config->get('fedex_weight_class_id')));

$date = time();

$day = date('l', $date);

if ($day == 'Saturday') {
$date += 172800;
} elseif ($day == 'Sunday') {
$date += 86400;
}

$this->load->model('localisation/country');

$country_info = $this->model_localisation_country->getCountry($this->config->get('config_country_id'));

$this->load->model('localisation/zone');

$zone_info = $this->model_localisation_zone->getZone($this->config->get('config_zone_id'));

if (!$this->config->get('fedex_test')) {
$url = 'https://gateway.fedex.com/web-services/';
} else {
$url = 'https://gatewaybeta.fedex.com/web-services/';
}

// Whoever introduced xml to shipping companies should be flogged
$xml = '<?xml version="1.0"?>';
$xml .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://fedex.com/ws/rate/v10">';
$xml .= ' <SOAP-ENV:Body>';
$xml .= ' <ns1:RateRequest>';
$xml .= ' <ns1:WebAuthenticationDetail>';
$xml .= ' <ns1:UserCredential>';
$xml .= ' <ns1:Key>' . $this->config->get('fedex_key') . '</ns1:Key>';
$xml .= ' <ns1:Password>' . $this->config->get('fedex_password') . '</ns1:Password>';
$xml .= ' </ns1:UserCredential>';
$xml .= ' </ns1:WebAuthenticationDetail>';
$xml .= ' <ns1:ClientDetail>';
$xml .= ' <ns1:AccountNumber>' . $this->config->get('fedex_account') . '</ns1:AccountNumber>';
$xml .= ' <ns1:MeterNumber>' . $this->config->get('fedex_meter') . '</ns1:MeterNumber>';
$xml .= ' </ns1:ClientDetail>';
$xml .= ' <ns1:Version>';
$xml .= ' <ns1:ServiceId>crs</ns1:ServiceId>';
$xml .= ' <ns1:Major>10</ns1:Major>';
$xml .= ' <ns1:Intermediate>0</ns1:Intermediate>';
$xml .= ' <ns1:Minor>0</ns1:Minor>';
$xml .= ' </ns1:Version>';
$xml .= ' <ns1:ReturnTransitAndCommit>true</ns1:ReturnTransitAndCommit>';
$xml .= ' <ns1:RequestedShipment>';
$xml .= ' <ns1:ShipTimestamp>' . date('c', $date) . '</ns1:ShipTimestamp>';
$xml .= ' <ns1:DropoffType>' . $this->config->get('fedex_dropoff_type') . '</ns1:DropoffType>';    
$xml .= ' <ns1:PackagingType>' . $this->config->get('fedex_packaging_type') . '</ns1:PackagingType>';    
$xml .= ' <ns1:Shipper>';
$xml .= ' <ns1:Contact>';
            $xml .= ' <ns1:PersonName>' . $this->config->get('config_owner') . '</ns1:PersonName>';
            $xml .= ' <ns1:CompanyName>' . $this->config->get('config_name') . '</ns1:CompanyName>';
            $xml .= ' <ns1:PhoneNumber>' . $this->config->get('config_telephone') . '</ns1:PhoneNumber>';
           $xml .= ' </ns1:Contact>';
$xml .= ' <ns1:Address>';

if ($country_info['iso_code_2'] == 'US') {
$xml .= ' <ns1:StateOrProvinceCode>' . ($zone_info ? $zone_info['code'] : '') . '</ns1:StateOrProvinceCode>';
} else {
$xml .= ' <ns1:StateOrProvinceCode>' . ($zone_info ? $zone_info['name'] : '') . '</ns1:StateOrProvinceCode>';
}

$xml .= ' <ns1:PostalCode>' . $this->config->get('fedex_postcode') . '</ns1:PostalCode>';
$xml .= ' <ns1:CountryCode>' . $country_info['iso_code_2'] . '</ns1:CountryCode>';
$xml .= ' </ns1:Address>';
$xml .= ' </ns1:Shipper>';

$xml .= ' <ns1:Recipient>';
$xml .= ' <ns1:Contact>';
$xml .= ' <ns1:PersonName>' . $address['firstname'] . ' ' . $address['lastname'] . '</ns1:PersonName>';
$xml .= ' <ns1:CompanyName>' . $address['company'] . '</ns1:CompanyName>';
$xml .= ' <ns1:PhoneNumber>' . $this->customer->getTelephone() . '</ns1:PhoneNumber>';
$xml .= ' </ns1:Contact>';
$xml .= ' <ns1:Address>';
$xml .= ' <ns1:StreetLines>' . $address['address_1'] . '</ns1:StreetLines>';
$xml .= ' <ns1:City>' . $address['city'] . '</ns1:City>';

if ($address['iso_code_2'] == 'US') {
$xml .= ' <ns1:StateOrProvinceCode>' . $address['zone_code'] . '</ns1:StateOrProvinceCode>';
} else {
$xml .= ' <ns1:StateOrProvinceCode>' . $address['zone'] . '</ns1:StateOrProvinceCode>';
}

$xml .= ' <ns1:PostalCode>' . $address['postcode'] . '</ns1:PostalCode>';
$xml .= ' <ns1:CountryCode>' . $address['iso_code_2'] . '</ns1:CountryCode>';
$xml .= ' <ns1:Residential>' . ($address['company'] ? 'true' : 'false') . '</ns1:Residential>';
$xml .= ' </ns1:Address>';
$xml .= ' </ns1:Recipient>';
$xml .= ' <ns1:ShippingChargesPayment>';
$xml .= ' <ns1:PaymentType>SENDER</ns1:PaymentType>';
$xml .= ' <ns1:Payor>';
            $xml .= ' <ns1:AccountNumber>' . $this->config->get('fedex_account') . '</ns1:AccountNumber>';
            $xml .= ' <ns1:CountryCode>' . $country_info['iso_code_2'] . '</ns1:CountryCode>';
           $xml .= ' </ns1:Payor>';
$xml .= ' </ns1:ShippingChargesPayment>';
$xml .= ' <ns1:RateRequestTypes>' . $this->config->get('fedex_rate_type') . '</ns1:RateRequestTypes>';
$xml .= ' <ns1:PackageCount>1</ns1:PackageCount>';
$xml .= ' <ns1:RequestedPackageLineItems>';
$xml .= ' <ns1:SequenceNumber>1</ns1:SequenceNumber>';
         $xml .= ' <ns1:GroupPackageCount>1</ns1:GroupPackageCount>';
$xml .= ' <ns1:Weight>';
$xml .= ' <ns1:Units>' . $weight_code . '</ns1:Units>';
$xml .= ' <ns1:Value>' . $weight . '</ns1:Value>';
$xml .= ' </ns1:Weight>';
$xml .= ' <ns1:Dimensions>';
$xml .= ' <ns1:Length>20</ns1:Length>';
$xml .= ' <ns1:Width>20</ns1:Width>';
$xml .= ' <ns1:Height>10</ns1:Height>';
$xml .= ' <ns1:Units>IN</ns1:Units>';
$xml .= ' </ns1:Dimensions>';
$xml .= ' </ns1:RequestedPackageLineItems>';
$xml .= ' </ns1:RequestedShipment>';
$xml .= ' </ns1:RateRequest>';
$xml .= ' </SOAP-ENV:Body>';
$xml .= '</SOAP-ENV:Envelope>';    

$curl = curl_init($url);

curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($curl);

curl_close($curl);

$dom = new DOMDocument('1.0', 'UTF-8');
$dom->loadXml($response);    

if ($dom->getElementsByTagName('HighestSeverity')->item(0)->nodeValue == 'FAILURE' || $dom->getElementsByTagName('HighestSeverity')->item(0)->nodeValue == 'ERROR') {
$error = $dom->getElementsByTagName('HighestSeverity')->item(0)->nodeValue;
} else {
$rate_reply_details = $dom->getElementsByTagName('RateReplyDetails');

foreach ($rate_reply_details as $rate_reply_detail) {
$code = strtolower($rate_reply_detail->getElementsByTagName('ServiceType')->item(0)->nodeValue);

if (in_array(strtoupper($code), $this->config->get('fedex_service'))) {
$title = $this->language->get('text_' . $code);

if ($this->config->get('fedex_display_time')) {
$title .= ' (' . $this->language->get('text_eta') . ' ' . date($this->language->get('date_format_short') . ' ' . $this->language->get('time_format'), strtotime($rate_reply_detail->getElementsByTagName('DeliveryTimestamp')->item(0)->nodeValue)) . ')';
}

$total_net_charge = $rate_reply_detail->getElementsByTagName('RatedShipmentDetails')->item(0)->getElementsByTagName('ShipmentRateDetail')->item(0)->getElementsByTagName('TotalNetCharge')->item(0);

$cost = $total_net_charge->getElementsByTagName('Amount')->item(0)->nodeValue;

$currency = $total_net_charge->getElementsByTagName('Currency')->item(0)->nodeValue;

$quote_data[$code] = array(
'code' => 'fedex.' . $code,
'title' => $title,
'cost' => $this->currency->convert($cost, $currency, $this->config->get('config_currency')),
'tax_class_id' => $this->config->get('fedex_tax_class_id'),
'text' => $this->currency->format($this->tax->calculate($this->currency->convert($cost, $currency, $this->currency->getCode()), $this->config->get('fedex_tax_class_id'), $this->config->get('config_tax')), $this->currency->getCode(), 1.0000000)
);
}
}
}
}

$method_data = array();

if ($quote_data || $error) {
$title = $this->language->get('text_title');

if ($this->config->get('fedex_display_weight')) {
$title .= ' (' . $this->language->get('text_weight') . ' ' . $this->weight->format($weight, $this->config->get('fedex_weight_class_id')) . ')';
}

$method_data = array(
'code' => 'fedex',
'title' => $title,
'quote' => $quote_data,
'sort_order' => $this->config->get('fedex_sort_order'),
'error' => $error
);
}

return $method_data;
}
}    
?>
于 2015-03-16T12:46:41.850 回答
0

我终于在 Fedex 支持的帮助下解决了这个问题。

事实证明,我使用的帐户凭据与另一家母公司相同,因此我需要注册一个单独的帐户。

于 2013-10-25T23:23:52.553 回答